开发者

Writing High Performance Server. Which method?

开发者 https://www.devze.com 2023-02-19 05:14 出处:网络
if you would need to write a high performance server how would you do it? Using asynchronous blocking epoll / kqueue?

if you would need to write a high performance server how would you do it?

  • Using asynchronous blocking epoll / kqueue? But how to handle the blocking System call epoll / kqueue here? Perhaps with a Main thread which uses worker Threads which perform the blocking epoll/kqueue ?
  • Usi开发者_StackOverflow社区ng libevent? Does it even differs from epoll/kqueue as it only capsulates different mechanisms like select, epoll, kqueue etc?
  • Or instead using asynchronous blocking epoll/kqueue using Asynchronous non blocking libaio? But does it even support Sockets or just Disk IO?

Thank you for your answers.


I would use libevent.

It uses the best available mechanism on the target platform, whatever that mechanism may be; so, without changes, your program will use kqueue on BSD, epoll(4) on Linux, and whatever else is best on whatever else might exist, while still falling back to select(2) on old platforms, and somehow it also works on Windows.

Magical software. :)


I would use boost::Asio
It uses best non blocking IO per system

  • epoll for linux
  • kqueue for NIX like
  • overlapped I/O on Windows

It can handle other streams as well (COM, files).
Concept is simple create io_service class and write handle (event like) classes to manage stream.

0

精彩评论

暂无评论...
验证码 换一张
取 消