In the process of my question here Production server much slower then local test server when sending large request I am trying to understand more profoundly what a webserver - especially nginx - actually does. Basically I want to understand better the architecture that I took for granted a long time. Maybe it's trivial but please hear me out...
I am running a django app with nginx and gunicorn and I am sending post-requests to the server. Since I am trying to understand where my performance problems are I want to understand in detail how my requests are being treated.
So I am sending a POST-request via the library requests
. As I understand it, every data sent in the internet is using the HTTP
-protocol, so basically the data I am sending is transmitted in text-format. Correct? There is no code interpretation of python objects/data-structures whatsoever? So the size of a request reaching nginx is only the size of the request converted to text-format?
As I further understand this, nginx now receives this request in text-format and then decides what to do with this request... It forwards this request to my web (django) application (or maybe better: my backend server) where my code is being executed and where the data is written into the DB.
So does nginx solely forward the request and that's it? Or does it do anything else?
Then the code or the Database throw an error or give back a success message to nginx which nginx returns as server output (like 404 or 405 or 201 or whatever code...).
SO my question is: How is nginx treating these API requests and how are they interpreted?
nginx simply forwards the request to your backend server. It doesn't do any additional operations on the data except compression if so negotiated with the client.
In 99% of the cases, there is nothing in nginx that could significantly affect performance. It is the actual application that needs to be analyzed for performance issues.