Introduction
In modern software development, seamless interoperability between different programming languages is often a key requirement. Teams frequently face the challenge of connecting applications written in JavaScript with backend logic implemented in Python. The most common approach is to expose Python functionality over REST APIs, which provides flexibility but also introduces serialization overhead, network latency, and infrastructure complexity.
In this article, we present a benchmark comparison of Javonet vs REST for JavaScript-to-Python calls. Our goal is to evaluate performance differences, identify potential bottlenecks, and provide practical insights into when each approach may be the best fit.
Test Environment
OS: Windows 11
CPU/RAM: Intel Core i7-1355U/32GB
Docker: 28.3.3
Node.js: 22.19
Python: 3.12
Flask code
Let’s create a simple Flask application that exposes endpoint getstring:
We create a Dockerfile based on a slim Python image, copy the application and requirements, install dependencies, and run the app:
Let’s build docker image and start container:
In the same directory as the .py file, let’s create a requirements.txt:
Fast API
Same thing we can do with FlaskApi:
Dockerfile:
In the same directory as the .py file, let’s create a requirements.txt:
Python code called by Javonet
Now we will create a simple Python application that serves the same function as the previous API, but this time it will be invoked through Javonet code. Let’s create MyClass.py:
We also need to download the gg file and place it in the same directory as MyClass.py and the Dockerfile.
Our Dockerfile should look like this:
And we can run it:
Testing code
Now we can move on to creating the JavaScript code that will test the Docker containers we have prepared.
For sample tests on our hardware, we obtained the following results (ms):
Conclusion
The benchmarks show that Javonet consistently outperforms REST-based approaches when calling Python from JavaScript. Across 100, 1,000, and 10,000 calls, Javonet maintained the lowest average latency (around 2 ms), slightly ahead of FastAPI and far faster than Flask, which stayed above 8 ms. While REST remains valuable for distributed systems, Javonet offers a clear advantage when low latency and maximum performance are required.
Introduction
In modern software development, seamless interoperability between different programming languages is often a key requirement. Teams frequently face the challenge of connecting applications written in JavaScript with backend logic implemented in Python. The most common approach is to expose Python functionality over REST APIs, which provides flexibility but also introduces serialization overhead, network latency, and infrastructure complexity.
In this article, we present a benchmark comparison of Javonet vs REST for JavaScript-to-Python calls. Our goal is to evaluate performance differences, identify potential bottlenecks, and provide practical insights into when each approach may be the best fit.
Test Environment
OS: Windows 11
CPU/RAM: Intel Core i7-1355U/32GB
Docker: 28.3.3
Node.js: 22.19
Python: 3.12
Flask code
Let’s create a simple Flask application that exposes endpoint
getstring:We create a Dockerfile based on a slim Python image, copy the application and requirements, install dependencies, and run the app:
Let’s build docker image and start container:
In the same directory as the
.pyfile, let’s create arequirements.txt:Fast API
Same thing we can do with FlaskApi:
Dockerfile:
In the same directory as the
.pyfile, let’s create arequirements.txt:Python code called by Javonet
Now we will create a simple Python application that serves the same function as the previous API, but this time it will be invoked through Javonet code. Let’s create
MyClass.py:We also need to download the
ggfile and place it in the same directory as MyClass.py and theDockerfile.Our
Dockerfileshould look like this:And we can run it:
docker build -t pythonclass . # Use different ports than before. docker run -p 8082:80 -p 8083:81 pythonclassTesting code
Now we can move on to creating the JavaScript code that will test the Docker containers we have prepared.
For sample tests on our hardware, we obtained the following results (ms):
Conclusion
The benchmarks show that Javonet consistently outperforms REST-based approaches when calling Python from JavaScript. Across 100, 1,000, and 10,000 calls, Javonet maintained the lowest average latency (around 2 ms), slightly ahead of FastAPI and far faster than Flask, which stayed above 8 ms. While REST remains valuable for distributed systems, Javonet offers a clear advantage when low latency and maximum performance are required.