spring boot application in cluster

19,250

Solution 1

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.

Solution 2

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.

Solution 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

Share:
19,250
mahendra kawde
Author by

mahendra kawde

Updated on June 12, 2022

Comments

  • mahendra kawde
    mahendra kawde about 2 years

    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 ?