Multithreaded web server versus single-threaded

We have a simple web server for internal use, which has only one function: listen to requests, read them and click data in the database. The DB and the web server are located on the same machine. Db is mysql-db, and server is a python ( BaseHTTPServer.HTTPServer) web server that works on a single thread.

The problem is that two requests cannot be processed simultaneously. The question is, will it help make a multi-threaded web server (using django, cheryypy, ..)? Intuitively, the web server only performs tasks related to processor consumption, so changing it in a multi-threaded should not help. Is it correct?

+3
source share
5 answers

Having multiple threads or processes will really help you (which is actually required in practice) when you want to process more than one request at a time.

This does not mean that two requests will be processed faster. Having a pool of processes or threads is very useful for web server performance, but it is not very noticeable in such cases (if you do not have multiple cores). But MySQL has no problems processing two queries at the same time, so if your web server can also do this, you will get rid of the problem of processing only one query.

But if you should start using such a server, you can answer. :) Django is definitely crowded anyway, look at the small WSGI server.

+2
source

1. Apache. , . Apache . .

, .

2. , wsgi wsgiref. , , -.

3. mod_wsgi Apache. . concurrency.

. WSGI.

+1

- , ( , - ), .

. , . , -, , .

0

, , , Django Cherrypy - WAY, .

, , , - , , , . , , accept() .

0
source

You must use a multithreaded or asynchronous web server, otherwise each request is blocked. Django is a web framework, you may have to look for scripts that you can transparently replace in your current setup and still have your own clean multithreaded python web server. Otherwise, twisted is also a good solution. AFA. I see you might not need the Web Framework because you are not using an application with an MVC pattern.

0
source

Source: https://habr.com/ru/post/1780633/


All Articles