En publicaciones anteriores, hemos hablado mucho sobre todas las capacidades de Flogo y cómo hacer diferentes tipos de cosas con Flogo, y un mensaje siempre se subrayó allí: rendimiento, rendimiento, rendimiento… pero ¿cómo se compara el rendimiento de Flogo con otros lenguajes de programación modernos?
Para poder compartir algunos datos reales, lo mejor que podemos hacer es realizar nuestra prueba. Para hacer nuestra prueba, vamos a comparar nuestro desarrollo en Flogo frente al mismo usando Python.
Podrías preguntar por qué estamos comparando desarrollos en Flogo y desarrollos en Python y la respuesta es muy simple. Python es ahora uno de los lenguajes más de moda, recientemente agregado como el tercer lenguaje principal en el Índice TIOBE y el lenguaje principal cuando hablamos de scripting de ciencia de datos:
Índice TIOBE que muestra a Python como el 3er lenguaje más usado
Escenario
Prueba 1
Nos gustaría probar ambas tecnologías, pero también ver cómo se comparan con la nueva realidad para microservicios y poder integrarse con Servicios en la Nube, y creemos que la mejor opción para esta prueba será usar Amazon S3 para poder ver cómo se desempeñan ambas tecnologías.
Entonces, vamos a subir archivos a Amazon S3 y ver cómo se desempeñan ambas tecnologías. Y seleccionamos las siguientes pruebas:
Archivo A: pequeño 138 KB. Número de iteraciones, 1, 10, 50.
Archivo B: mediano 7 MB. Número de iteraciones 1, 10, 50.
Archivo C: grande 50MB. Número de iteraciones 1, 10, 50.
Estamos usando el siguiente script de Python para probar la integración con S3:
import boto3
import time
import sys
import psutil
from botocore.exceptions import NoCredentialsError
Y vamos a usar la siguiente Aplicación Flogo (varios flujos para cada uno de los casos que nos gustaría verificar)
Prueba 2
Ahora, como esto va a ser para construir microservicios o aplicaciones en un mundo en la nube, veamos cómo se desempeñan ambos al hacer una simple API REST de Hello World. Para la parte de Python vamos a usar Flask para crear el servicio web y el siguiente fragmento:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "¡Hola Mundo!"
if __name__ == '__main__':
app.run(debug=True)
NOTA: Mantenemos el debug=True para hacerlo equivalente al nivel de sistema INFO predeterminado en la Aplicación Flogo
Y para Flogo un simple REST Hello World como este:
Flogo Hello World REST API
Resultados y Conclusiones
Prueba 1
Estamos obteniendo los siguientes números como puedes ver en el gráfico a continuación:
Incluso en este ejemplo de código bastante simple, el rendimiento de la aplicación Flogo es demasiado increíble para compararse con otro lenguaje bien ejecutado como Python.
Estamos hablando de un promedio de más del 50% más rápido el desarrollo en Flogo frente al de Python, y aún más cuando el tamaño del archivo es pequeño y lo más importante es cómo el lenguaje y las plataformas están manejando las cosas porque el porcentaje de tiempo respecto al ancho de banda no es lo suficientemente grande como para hacer que todos los valores dependan de la conexión que tengas disponible en ese momento.
Si hablamos sobre el consumo de memoria, los datos son bastante estables para ambos lenguajes, lo cual es una muy buena señal de cómo se maneja la memoria para esas plataformas. Pero en esta batalla también gana Flogo porque si usamos el último, el más grande, Flogo es estable en 22,7 MB frente a 55 MB de Python, también más del 50% mejor una vez más.
Prueba 2
Para los resultados del servicio API REST son bastante similares a los de la primera PRUEBA, y estamos viendo los siguientes resultados respecto a TPS y tiempo de respuesta:
Transacciones por segundo API REST Python vs FlogoTiempo de Respuesta API REST Python vs Flogo
Como podemos ver, en primer lugar, el tiempo de respuesta siempre es menor desde la API de Flogo (y recuerda que esta es una prueba predeterminada, sin ajustes especiales o algo similar) y también el tiempo de respuesta se desempeña mejor en Flogo, siendo capaz de mantenerse estable casi hasta 4 hilos y luego ser capaz de controlar el aumento mientras que el servicio REST de Python después de 2 hilos el tiempo de respuesta aumenta más del doble con cada prueba.
Lo mismo ocurre con respecto a TPS, donde en el caso de Flogo todos los valores son mejores que el anterior. Por supuesto, se alcanza algún tipo de límite en 8 hilos, pero en el caso de Python esta raíz se alcanza en 2 hilos y después de ese punto todos los valores son peores que el anterior.
En cuanto a la memoria, el consumo es bastante similar al de la prueba anterior, ambas soluciones mantienen el uso de memoria bastante bajo y estable. En este caso, Python siempre es estable en 20.3 MB y Flogo comienza en 15 MB pero alcanza su pico en 21.8 y luego vuelve a 18.8 MB. Así que, como dije, son bastante similares en cuanto al uso de memoria en esta prueba.
Consumo de Memoria Flogo vs Python
Conclusiones
Entonces, la conclusión es clara, no importa cuán bien creas que tu lógica se está ejecutando en Python, deberías intentar hacerlo usando Flogo porque, en este tiempo donde cada MB y cada milisegundo cuenta para hacer más pequeña tu factura de Infraestructura, Flogo va a ser tu mejor herramienta para exprimir todo el poder de tu infraestructura.
Recursos
Puedes encontrar todo el código que he usado para estas pruebas en el repositorio de GitHub que se muestra a continuación:
GitHub – alexandrev/flogo-vs-python-medium
Contribute to alexandrev/flogo-vs-python-medium development by creating an account on GitHub.
In previous posts, we’ve talked a lot about all the capabilities of Flogo and how to do different kinds of things with Flogo, and one message was always underlined there: performance, performance, performance… but how flogo performance is compared with other modern programming languages?
To be able to share some real data the best thing we can do is to do our test. To do our test we’re going to compare our Flogo development versus the same one using Python.
You could ask why we’re comparing Flogo developments and Python developments and the answer is very simple. Python is now one of the most trending languages, recently added as the 3rd top language in the TIOBE Index and the main language when we talked about data science scripting:
TIOBE index that shows Python as the 3rd more used language
Scenario
Test 1
We’d like to test both technologies but also see how they compared with the new reality for microservices and be able to integrate with Cloud Services and we think the best fit for this test will be using Amazon S3 to be able to see how both technologies perform.
So, we’re going to upload files to Amazon S3 and see how both technologies perform. And we select the following tests:
File A: small 138 KB. Number of iterations, 1, 10, 50.
File B medium 7 MB. Number of iterations 1, 10, 50.
File C: big 50MB. Number of iterations 1, 10, 50.
We’re using the following Python script for test the S3 integration:
import boto3
import time
import sys
import psutil
from botocore.exceptions import NoCredentialsError
And we’re going to use the following Flogo Application (several flows for each of cases we’d like to check)
Test 2
Now, as this is going to be to build microservices or applications in a cloud world let’s see how both perform doing a simple Hello World REST API. For the python part we’re going to use Flask to create the web service and the following snippet:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run(debug=True)
NOTE: We keep the debug=True to make it equivalent to the INFO default level system in Flogo Application
And for Flogo a simple REST Hello World like this:
Flogo Hello World REST API
Results and Conclusions
Test 1
We’re getting the following numbers as you can see in the graph below:
Even in this quite simple code sample, the performance of the Flogo application is too incredible to be compared with another well-performed language like Python.
We’re talking like an average of more than 50% faster the Flogo development vs the Python one, and even more when the size of the file is small and more important is how the language and the platforms are handling things because they percentage of time regarding bandwidth is not big enough to make that all the values depend on the connection you have available at that moment.
If we talk about memory consumptions data are pretty much stable for both languages what is a very good sign on how memory is handled for those platforms. But in this battle also Flogo wins because if we use the last one the biggest one, Flogo is stable at 22,7 MB vs 55 MB from Python, also more than 50% better once again.
Test 2
For the REST API service results are pretty similar to the ones from the first TEST, and we’re seeing the following results regarding TPS and Response time:
Transaction per seconds REST API Python vs FlogoResponse Time REST API Python vs Flogo
As we can see first of all the response time is always smaller from the Flogo API (and remember that this is a default test, with no special tuning or something similar) and also the response time is performing better in Flogo being able to keep stable almost until 4 threads and then being able to control the increase while Python REST service after 2 threads the response time increase more than twice with each test.
The same thing happens regarding TPS wherein the Flogo case all the values are better than the previous one. Of course, some kind of limit is reached at 8 threads but in the case of Python this root is reached at 2 threads and after that point all the values and worse than the previous one.
Regarding memory, consumption is pretty similar like the previous test both of the solutions keep memory usage quite low and stable. In this case, python is always stable at 20.3 MB and Flogo starts at 15 MB but reaches its peak at 21.8 and then go back to 18.8 MB. So as I said they’re pretty similar regarding memory usage in this test
Flogo vs Python Memory Consumption
Conclusions
So, the conclusion is clear, no matter how well you think your logic is executing in Python, you should give it a try to do it using Flogo because, in this time where each MB and each msec counts to make smaller your Infrastructure bill, Flogo is going to be your best tool to squeeze all the power of your infrastructure.
Resources
You can find all the code I’ve used for these tests in the GitHub repository shown below:
GitHub – alexandrev/flogo-vs-python-medium
Contribute to alexandrev/flogo-vs-python-medium development by creating an account on GitHub.