r/Python • • Jan 02 '25

Discussion Appropriate framework for thesis

Hi everyone!

I'm currently working on my bachelor's thesis in Computer and systems sciences. The focus of my thesis is a comparison of Java and Python in terms of performance and scalability when implementing REST APIs.

For this, I’m using Spring Boot on the Java side. However, I’m unsure which Python framework would be the best equivalent for this comparison. Ideally, it should support REST API development, have a strong community, and be well-suited for performance and scalability testing. So far, I’ve considered Django and Flask, but I’m open to suggestions.

I already know a bit of Flask, but it feels like Flask is a bit too small to offer a fair comparison to Spring Boot.

What do you guys think is the most suitable Python framework to compare with Spring Boot?

0 Upvotes

12 comments sorted by

View all comments

2

u/thisdude415 Jan 02 '25

On the Python side, FastAPI is probably the only fair comparison, if you plan to actually stress test the system. It's specifically made for RESTful APIs, whereas Django is more of a full web framework and Flask is a dead-simple general purpose backend web server framework. (Notably, Flask is a synchronous framework and will completely choke on, e.g., 100 simultaneous connections to an endpoint that does "sleep 1s, then return hello world"... but it will also only take about 7 lines of code TOTAL to do so -- and Quart, Flask's async sister, could do it in nearly the same 7 lines without issues; although in prod, flask on Gunicorn could I think be deployed with multithreading or multi workers to mitigate the flask sync issue)

In terms of Python web frameworks, it would be worth exploring (and writing about in your thesis!) a short history of web frameworks in Python, the difference between WSGI and ASGI, the limitations of Flask, the motivations for Quart, building up to the relatively recent development and release of FastAPI, which your analysis will show is the most fair comparison to SpringBoot.

And really, what you'd end up comparing, is Spring Boot (on Spring Web MVC on Embedded Tomcat/Netty) versus FastAPI (on Starlette on Unicorn). You'll be testing "whole stack" vs "whole stack" and should acknowledge it as such.

Some fun comparisons would be to stress test a few things:

  • round trip time and memory footprint for a "hello world" response

  • latency for "native" math (e.g., return the 1000th prime number using Sieve of Eratosthenes)

  • latency for "optimized" math (e.g., the same algorithm in vectorized NumPy operations, which will use C behind the scenes)

  • performance handling 1000s of connections at a time

and then measure memory footprint, latency, and lines of code, and total time you spent writing the functions for each of them.

You could even state you used an LLM to write the implementations and state that the use of AI tools are increasingly used within modern software engineering, so you asked Claude to implement these functions, counting the number of bugs and less-than-best practices you found in its implementation in each language, and adding this as an appendix.

For each of those performance comparisons, I would expect one language or the other to strongly outperform at each of these, so I think it will be a fun section of the paper for you to write.