Profiling Flask application to improve performance

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • flask-profiler

    a flask profiler which watches endpoint calls and tries to make some analysis.

  • There are a lot of profiling tools for Python code, and most of them are built-in — like profile or cProfile. Since I’m speaking about Flask application, let’s see what the world has especially for it. There is a beautiful lib called flask-profiler, which has a web interface with some cool features such as route or date filters. But Flask also has a built-in in werkzeug's profiler. It looked awesomely easy in use, so it was the first — and the last — one I tried. To use the built-in profiler you’ll need to add only two lines of code to your project:

  • gprof2dot

    Converts profiling output to a dot graph.

  • There are a few tools to visualise the profile dumps. Some of them providing a full GUI for navigatig within your profiling results ( RunSnakeRun), some of them represent the analysis result as a Graph (gprof2dot). I stopped on snakeviz, which is a browser based visualizer. It is easy installed using pip install snakeviz, and then simply run with snakeviz profile_dir. The result looks something like this, and you can dive in to each of the visual parts to see its more close detalization, which is in my opinion is super cool and handy.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts