eri
eri

Reputation: 3524

How start aiohttp app in multiple workers?

I want aiohttp app running on number of processes.

Tornado has

server = HTTPServer(app)
server.bind(8888)
server.start(0)

for starting workers (0 - cpu cores). I know about gunicorn. But i want server embeded into application.

Found https://docs.aiohttp.org/en/stable/web_reference.html#server how use it?

Upvotes: 0

Views: 1329

Answers (1)

MatsLindh
MatsLindh

Reputation: 52902

According to the documentation for aiohttp, running on multiple cores in a single application isn't supported.

Standalone

Just call aiohttp.web.run_app() function passing aiohttp.web.Application instance.

The method is very simple and could be the best solution in some trivial cases. But it does not utilize all CPU cores.

For running multiple aiohttp server instances use reverse proxies.

This means that it's outside of the responsibility of aiohttp to support multiple processes; instead leaving that part to supervisord (which nginx can then connect to in a round-robin fashion) or gunicorn w/nginx.

Upvotes: 1

Related Questions