0

While working with springboot in local environment, creating a REST application feels so effortless due to its embedded (and abstract) tomcat server. We can do so by creating a Restcontroller and routing the requests using annotations. But I am trying to understand the working of applications in production environment. I have following questions -

  1. What role will the springboot's embedded tomcat server will play when the application is deployed on to production servers?
  2. If I have a spring (not springboot) application and if I want to send out data from this application by exposing api's what steps should I take? P.S - In the spring application there is no tomcat or any such dependency. Please explain the relevance of using them along with how to use it.

Thanks

2 Answers 2

0

There is no particular issue to deploy an springboot application in production. It'is a simple process to run, you can manage this process using a container or service... https://docs.spring.io/spring-boot/how-to/deployment/installing.html

  1. springboot is an application server (with only one application) you can or not add a revers proxy (apache, nginx, treafik...)

  2. you need an application server like tomcat, jetty running as service. Next you have to deploy your war on it. You can expose directly or use a revers proxy same as springboot. Usually you just copy war file in a specific directory.

0

Spring boot with spring-boot-starter-web dependency (which brings Embedded Tomcat as the webserver) is vastly used for microservices architecture. This Embedded Web Server is powerful because you can scale your application without much effort (you scale without having to setup an actual application server like weblogic, tomcat, wildfly etc). This is the way to go with Spring Boot.

To answer your questions:

  1. The role is to provide your application with an HTTP Server layer, which manages the thread-pool used to serve those HTTP requests and handle those HTTP request and pass them to your MVC layer (rest controllers) -- just like it does on your development environment. Of course it may need some tuning such as specifying the server.tomcat.max-threads and other relevant properties (as you would do to any application deployed to production, being spring boot or not).

  2. You would build your app and deploy it alongside with it's dependencies to an application server such as tomcat, wildfly, weblogic, websphere etc.

As of today with corporations going to the direction of approaches like horizontal scaling, containerization etc, in my opinion, the best way to run Spring apps is to use an Embedded Web Server, even if you're not using Spring Boot -- yes, that is possible, but you will have to configure it yourself in your application (something that Spring Boot already do for you).

Not the answer you're looking for? Browse other questions tagged or ask your own question.