The Falcon Web Framework — Should You Use It?

Shreyas Sridhar
affinityanswers-tech
5 min readAug 12, 2021

Recently, at Affinity Answers, we had been looking for ways to make programmatic access to the information on our social insights platform, FanFinder360, available to our customers. This called for an intermediary server to be created in order to facilitate communication between the end user and the core application server. The new server had to be built on a framework that was speedy, robust and reliable, and this sparked the search for a new web framework that would match all our requirements. That’s when we stumbled upon Falcon.

Falcon is, as stated on their GitHub page, a low-level, high-performance Python framework for building HTTP APIs, app backends, and higher-level framework. In essence, it can be used as an alternative to Flask, Django and Bottle. But is it worth it?

This blog discusses the features of Falcon and NOT how to build a server using Falcon. This is explained in detail in the documentation for Falcon hosted on Read The Docs. You can find easy tutorials to help you create a WSGI application at https://falcon.readthedocs.io/en/stable/user/tutorial.html, and an ASGI application at https://falcon.readthedocs.io/en/stable/user/tutorial-asgi.html.

Falcon has many selling points, but here are some of the significant advantages of using the framework:

  • Speed: Falcon prides itself on being lightning quick. The minimalist nature of the design allows for greater speed while responding to requests.
  • Reliability: The Falcon framework is used by major corporations like PayPal and LinkedIn for critical systems, and can be relied on to remain robust.
  • RESTful: Falcon encourages the REST architectural style, employing HTTP method handlers to respond to requests.
  • Compatibility: Due to support for ASGI and WSGI, Falcon works with a wide variety of technologies. In addition to this, it can also be combined with CPython 3.5+ or Pypy for even faster execution times.

Here’s a complete list of features as given by Falcon on their official page:

A list of features of the Falcon framework as seen on their official website
Complete list of features

When I was first looking at Falcon, I was drawn to it for two major reasons — its speed, and its simplicity. Let’s take a look at how quick Falcon is. Here are some benchmark values as calculated by Falcon themselves. Of course, as per their disclaimer, these numbers may not be the same for all situations and use cases.

The speed up values of using Falcon with CPython as compared to other frameworks
The speed up values of using Falcon with Pypy as compared to other frameworks

From the data above, we can see that the combination of Falcon and Python3 is about 28 times faster than Django, while the combination of Falcon and Cython (with Cythonized code) is about 41 times faster. Finally, the combination of Falcon with Pypy3 is about 75 times faster than Django.

However, to test out this speed, I created a new test. In the following image, you can see the architecture that I used for my tests.

In the first case, I sent a direct request to a core API server, built with Django, and calculated the amount the server took to return a cached and uncached resource. In the second case, I sent a request to my intermediary API server, built with Falcon, which then sent a request to the core API server, and returned the response after performing certain extra operations like checking for rate limits, and logging. My goal was to test the latency created by using Falcon as an intermediary server and performing these extra operations.

Here are the results:

Benchmark results for the latency test
All values in seconds

As is visible above, the latency created by adding an intermediary Falcon server is only about 100 ms. This is a simple test, and the numbers will vary for different use cases. However, this test is one of main reasons I chose to use the Falcon framework.

Another reason is the simplicity — the ease with which a server can be created and maintained. Here is a sample of a very simple Falcon application that is shown on their official website.

Sample Falcon application

The application responds to requests made to the ‘/quote’ endpoint of the server and serves the quote stored in the ‘quote’ variable. In the second part of the image, you can see how easy it is to deploy the server with Gunicorn. Of course, not all applications and servers are going to be this easy to create, but Falcon is incredibly easy to learn and takes almost no time to get started with.

As mentioned above, there are in-depth tutorials to create and deploy WSGI and ASGI servers in the Falcon documentation.

Another cool feature of Falcon is that it comes with a bunch of inbuilt responses to standard problems, such as ‘404 Not Found’, ‘500 Internal Server Error’, etc. This means that you need not worry about every single edge case when you create your application, Falcon takes care of that for you.

In conclusion, the Falcon Web Framework is a very minimal and robust piece of software that can be used extensibly with other Python libraries in order to create a fast, reliable and well-structured server. It can be used to create quick, RESTful web servers that need to be brought up with minimal effort and little time or large scale projects that are required to be reliable and robust. It is versatile and an easy option, if you’re looking for a web framework.

--

--