5

I am developing a spring boot application.

Since spring boot created a .jar file for an application. I want to cluster this particular application on different server. Lets say I build a jar file and ran a project then it should run in cluster mode from number of defined servers and should be able to serve end user needs.

My jar will reside on only one server but it will be clustered across number of servers. When end user calls a web service from my spring boot app he never know from where it is getting called.

The reason behind clustering is suppose any of the server goes down in future, end user will still be able to access web services from another server. But I don't know how to make it clustered.

Can any one please give me insight on this ?

roeygol
  • 4,908
  • 9
  • 51
  • 88
mahendra kawde
  • 855
  • 4
  • 25
  • 44

4 Answers4

3

If you want to have it clustered, you just run your Spring Boot application on multiple servers (of course, the JAR must be present on those servers, otherwise you can't run it). You would then place a loadbalancer in front of the application servers to distribute the load.

dunni
  • 43,386
  • 10
  • 104
  • 99
  • Hey dunni thanks for your response. Can you please share any such doc explaining this process. – mahendra kawde Oct 05 '15 at 12:34
  • http://projects.spring.io/spring-cloud/ https://en.wikipedia.org/wiki/Load_balancing_(computing) nginx.org/en/docs/http/load_balancing.html – dunni Oct 05 '15 at 12:39
  • There are so many projects mentioned, so which one suites my requirement according to you – mahendra kawde Oct 05 '15 at 12:40
  • 1
    You haven't specified your requirements in detail, so it's not possible to answer that. Also this problem exceeds the scope of this site. If you have a specific problem with your code, you can ask for that. However, this site is not for general purpose questions. – dunni Oct 05 '15 at 12:50
  • 1
    Actually i just want to cluster an application for high availability. – mahendra kawde Oct 05 '15 at 13:06
  • How does the load balancing works when it comes to spring boot application ? – mahendra kawde Oct 06 '15 at 06:09
  • A typical loadbalancing doesn't care, what type of application there is. It is not different to a deployment scenario with application servers like WebSphere or JBoss. The loadbalancer just spread the requests to the application instances, that are running. – dunni Oct 06 '15 at 07:44
  • I googled and found that there are some Netflix API like Eureka, Hystrix, Ribbon and archaius. But can not find how these terms helps to distribute request and balance load at the same time provide high reliability and availability. – mahendra kawde Oct 06 '15 at 07:54
3

If all services you are going to expose are stateless so you only need to use load balancer in front of your nodes for ex. apache or nginx, if your services are stateful "store any state [session, store data in db]" so you have to use distributed cache or in memory data grid:

  1. for session you can use spring-session project which could used rails to store sessions.
  2. for store data in DB you need to cluster DB it self and can use distributed cache above your DB layer like Hazelcast.
Bassem Reda Zohdy
  • 12,662
  • 3
  • 33
  • 39
3

Look into spring cloud, they have used some netflix open software along with amazons to create 12 factor apps for micro services. Ideally you would need a load balancer, service registry that can help you achieve multiple instances of spring boot. I believe you have to add a dependency called eureka. Check the below link

Spring cloud

ScanQR
  • 3,740
  • 1
  • 13
  • 30
jtkSource
  • 675
  • 9
  • 21
0

You can deploy it in cloud foundry and use autoscale function to increase your application instances.

王子1986
  • 3,019
  • 4
  • 31
  • 43