服务器设计模式/最佳实践的最佳来源是什么?
我已经寻找一本涵盖服务器设计模式的好书一段时间了。我正在寻找类似《四人帮》的东西。
概念包括:
--线程、进程、基于组合的解决方案
-- 如何正确分类请求。即我预计来自任何域的请求都是有限的,因此我只能为每个域分配一定数量的工作人员。
-- 工作线程超时
-- poll/select/epoll 用例
——还有那些我不知道的事情!
有什么建议请提出来!
谢谢!
I've searched for a while for a good book which covers server designed patterns. I'm looking for something along the lines of Gang of Four.
Concepts include:
-- Threaded vs Process vs combo based solutions
-- How to triage requests properly. i.e. I expect only limited requests from any domain, so I may only allocate a certain number of workers per domain.
-- Worker timeouts
-- poll/select/epoll use cases
-- And those things I don't know!
Any suggestions please!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两本非常有用的书:
企业应用程序架构模式
企业集成模式:
Two very useful books:
Patterns of Enterprise Application Architecture
Enterprise Integration Patterns:
Unix 环境中的高级编程,第二版 是学习Unix系统编程的细节。它写得非常好(我最喜欢的英语书籍之一),深度非常好,并且对四种常见环境的关注(在出版时)有助于确保它的全面性。它并不算太过时——较新操作系统中的新功能可能对特定问题非常有用,但这本书确实很好地涵盖了基础知识。
当然,缺点是 APUE2nd 错过了一些出色的第三方工具,例如 libevent< /a>,这可以使基于套接字的服务器编程变得更加容易。 (并自动选择
select(2)
、poll(2)
、epoll(4)
、kpoll< 中的“最佳” /code>,以及针对平台的 Windows 事件处理。)
至于在线程和进程之间进行选择,归结为:您希望/需要在任务之间共享多少内存?如果每个进程都可以相对独立地运行,则进程可以提供更好的内存保护并且不会造成速度损失。如果进程需要与彼此的对象或单个线程“拥有”的对象进行交互,则线程可以提供更好的原语来共享数据。 (但许多人会认为线程的共享内存会引发有趣且令人兴奋的错误。这取决于情况。)
Advanced Programming in the Unix Environment, 2nd Edition is a fantastic resource for learning the details of Unix systems programming. It's extremely well-written (one of my favorite books in the English Language), the depth is excellent, and the focus on four common environments (at the time of publication) help ensure that it is well-rounded. It's not too badly out of date -- new features in newer operating systems may be fantastic for specific problems, but this book really covers the basics very well.
The downside, of course, is that APUE2nd misses out on some fantastic third-party tools such as libevent, which can make programming sockets-based servers significantly easier. (And automatically picks the 'best' of
select(2)
,poll(2)
,epoll(4)
,kpoll
, and Windows event handling, for the platform.)As for choosing between threads and processes, it comes down to: how much memory sharing do you want / need between tasks? If each process can run relatively isolated, processes provide better memory protection and no speed penalty. If processes need to interact with each other's objects, or objects 'owned' by a single thread, then threads provide better primitives for sharing data. (But many would argue that the shared memory of threads is an invitation to fun and exciting bugs. It Depends.)