What is the best way for server to achieve high performance with Python asyncio API?

126 views
Skip to first unread message

Yusuke Nishioka

unread,
Apr 27, 2022, 10:30:00 PM4/27/22
to grpc.io
My ideas are:

  • Multithreading using [migration_thread_pool](https://grpc.github.io/grpc/python/grpc_asyncio.html#create-server). Each thread has its own event loop and coroutines can be executed in different threads and it could utilize all CPUs. But coroutines must be thread-safe as coroutines executed in different threads can access the same data.
  • Multiprocessing. Each process has its main thread where event loop runs. In this case we don't need care about thread-safety as each process has its own memory space. Also read-only large data such as machine learning models can be shared in copy-on-write manner.

Which is better or is there any better way? Any other considerations?
Reply all
Reply to author
Forward
0 new messages