How performant can be your services with Flogo? (Flogo vs Python)

Image for post
Image for post

Introduction

In previous posts, we’ve talked a lot about all the capabilities of Flogo and how to do different kind of things with Flogo, and one message was always underline there: performance, performance, performance… but how performance is Flogo 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 were comparing it 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:

Image for post
Image for post
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 then best fit for this test will be using Amazon S3 to be able to see how this both technologies performs.

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 boto3import timeimport sysimport psutilfrom botocore.exceptions import NoCredentialsErrorACCESS_KEY = 'XXXXXXXXXXXXXXXXX'SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'def upload_to_aws(local_file, bucket, s3_file):       s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,       aws_secret_access_key=SECRET_KEY)       try:           s3.upload_file(local_file, bucket, s3_file)          print("Upload Successful")          return True       except FileNotFoundError:          print("The file was not found")          return False       except NoCredentialsError:          print("Credentials not available")          return Falsedef launch():    start = time.time()    for x in range(0, int(sys.argv[1])):    uploaded = upload_to_aws('D:/Data/Downloads/export.sql', 'testflogovspython', 'export.sql')    end = time.time()    print("Time: " +  str(end - start))launch()

And we’re going to use the following Flogo Application (several flows for each of cases we’d like to check)

Image for post
Image for post

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 Flaskapp = 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:

Image for post
Image for post
Flogo Hello World REST API

Results and Conclusions

Test 1

We’re getting the following numbers as you can see in the graph below:

Image for post
Image for post

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.

Image for post
Image for post

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.

Image for post
Image for post

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:

Image for post
Image for post
Transaction per seconds REST API Python vs Flogo
Image for post
Image for post
Response 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

Image for post
Image for post
Image for post
Image for post
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 show below:

PSG Senior Architect at TIBCO Software with a focus on Cloud Development, Event Processing and Enterprise Integration

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store