如何对 Spring 进行集群和负载平衡 + OSGi应用程序
我正在考虑使用 Spring 和 OSGi 开发一个 Web 应用程序。看起来他们在一起很般配。此类应用程序的集群和负载平衡有哪些选项?每种选项的优缺点是什么?
I am considering to develop an web application with Spring and OSGi. It seems like they fit together nicely. What are the options for clustering and loadbalancing such an app and what are the pros and cons of each?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OSGi 和 Spring 都不是为了解决高可用性、集群或负载平衡等问题而创建的。当然,您可以使用 Spring 和 OSGi 构建集群和负载平衡系统,但您可能还需要其他东西,例如检测和传达节点故障和负载级别的方法。
由于您正在构建 Web 应用程序,因此您很可能会使用众多应用程序服务器之一。好的AS产品可以为你提供集群。有些还提供负载平衡。您还可以通过自己完全独立的设置来实现负载平衡,例如使用 Apache 作为主应用程序服务器的前端。
如果您真的想创建自己的解决方案,我已经看到 JGroups 被用于多个产品中以提供构建集群和/或负载平衡解决方案所需的基础设施。例如,一些分布式内存缓存产品使用 JGroup。
谈到分布式缓存,Ehcache 等产品可以帮助解决扩展和负载平衡问题。
Neither OSGi nor Spring were created to solve problems such as high-availability, clustering or load-balancing. You could, of course, build a clustered and load-balanced system using Spring and OSGi, but you are probably going to need something else as well, such as a way to detect and communicate node failures and load levels.
Since you are building a web application, most likely you will be using one of the many application servers. Good AS products provide clustering for you. Some also provide load balancing. You can also achieve load balancing through a completely independent setup of your own, using Apache for example to front your main application servers.
If you are really bent on creating your own solution, I have seen JGroups being used in multiple products to provide the necessary infrastructure to build a clustering and/or load-balancing solution. Some of the distributed in-memory caching products use JGroups, for example.
Talking about distributed caches, products such as Ehcache can help with scaling and load-balancing problems.