Spring Boot + Tomcat - Microservices solution - spring-boot

I'm planning to expose few microservices (~20 at this stage) using Spring Boot. I will be creating executable fat jars using the embededed Tomcat. The executable jar will be wrapped in Docker container and deployed to AWS.
In my case 20 jars will have 20 tomcat instances running at the same time. I'm concerned about the overhead of running so many tomcat instances in the production server. Is this a valid concern?
I was wondering if someone has used something similar configuration in production and can share their experience.
Any suggestions will be appreciated.
Thanks
JP

We currently use AWS and Spring Cloud / Spring Boot. Our stance is instances that require more resources receive their own EC2 instance. Services that can be deployed using Docker are deployed to Amazon ECS.
All of our deployments are fat jars using embedded Tomcat.
Not knowing the size of what you are calling a service makes this answer a little complicated. If you are worried about Tomcat's overhead why are you running these services in Docker containers? Ease of deployment?
If you do go the route of deploying multiple services to the same Tomcat instance, I would not define your setup as a microservices based configuration.

You may try to deploy all your services (webapps) into one or more tomcat instances. You may not include the Tomcat into war file. Example maven/spring configuration you may find here

Related

How do people host Spring Boot apps with WebFlux on Reactor Netty in production?

I know it's a vague question but that's because I am not clear enough on what people are doing to ask anything more specific. I currently run my own apps with the embedded reactor netty server for development and basically push the embedded server inside a jar to cloud foundry to run the embedded server in production.
What are the other ways out there to set up a production environment for reactive reactor netty apps that people are using, or any documentation you might have seen?
I'm no sure that there is any difference between hosting the reactive spring-webflux application and regular applications.
Spring boot creates a jar with everything bundled inside (netty or more old-school tomcat) - it doesn't matter.
Then you can take this and run it "as is" on your server (on-premise, cloud ec2 style whatever you have, this really depends on your organization) directly with java -jar app.jar
Or, if you have more advanced needs/setup:
"Containerize" the application and create a docker (usually, although there are alternatives) image that runs the spring boot application. and then deploy it on kubernetes cluster, for example. At this point you should really consult with your DevOps people so that they'll tell you what is the way of deployment in your organization.
Besides kubernetes cluster there are many other alternatives:
- cloud provider specific solutions, like ECS or Fargate in amazon AWS
- Docker Swarm to name a few
All these solutions are pretty advanced, allow auto-scaling, advanced liveness monitoring and so forth. As an organization you usually pick the one that meets your needs

Spring boot and Tomcat : Is it better to use embeded Tomcat or external Tomcat installation.

I was wondering if some experienced spring boot users can tell us how to choose between embedded Tomcat and external Tomcat installation.
Thanks in advance.
Embedded Tomcat helps you to define Standalone application. Earlier we have to deploy war to Tomcat Server which itself a tedious task. From the embedded tomcat you can run application as service without worrying about the deployment thing. As now days microservices are being popular, spring boot is more popular because of its feature one of them is embedded servers like Tomcat,Jetty or Netty.

Spring Boot hot deployment in production

I have multiple spring boot based micro services. Can we enable hot deployment of those micro services in production environment. If yes how we can do it. Please note : currently we don't have docker. And though the services artifacts are jar, we can turn those to war.
Hot deployment is not a feature of Spring Boot so it's not correct to consider it configurable (enabled or disabled).
Hot deployment is a feature of application servers (tomcat, jboss, jetty, etc) where you deploy your WARs. If they supports hot deployment (most of them do!) then it's OK to replace WARs on-the-fly so they will be re-deployed.

Cloud Foundry : Spring boot vs WAR file

I am new to the world of Cloud, CloudFoundry, Saas, PaaS, IaaS, etc.
So I have few very fundamental questions.
Who is better Spring boot or war file in terms of deploying an application or a service to a cloud using cloud foundry?
WHY ?
If I want to deploy my war file on a PaaS cloud then who kicks it off?
As in where is the server?
How will I know which server my war file is deployed to?
Is using Spring-boot with embeded tomcat for PaaS mandatory?
What if my application does not use spring-boot (no spring reference in pom as well) then can I deploy my application war file on cloud? How?
There is nothing like better in war or Spring boot jar. They both are underhood same things, where Spring boot jar manages the server embedded in it and war does not have that.
Cloud Foundry has something like BuildPacks. You need to define a buildpack when you do a cf push. If you select a java build pack it has the things required to run a war on server. It gets the Java, Tomcat Server and all other dependencies needed to run the war.
https://github.com/cloudfoundry/java-buildpack
Cloud foundry creates a droplet, which is basically the execution context with all required dependencies. This is used to run the actual VM on the cloud.
You need not know which server your war is deployed to. That is the basic idea behind the cloud deployment. It may be on a single/multiple VMs under the hood. So what you need to know is something called routes. Routes are the actual addresses to your apps. You need to create routes and bind them to your application, and later app can be accessed using the routes.
https://docs.cloudfoundry.org/devguide/deploy-apps/routes-domains.html#routes
No using embedded servers is not mandatory in Any Cloud PAAS. War can be directly deployed. All PAAS platforms has support for this. Cloud foundry way of doing this is through build packs.
CF : https://docs.cloudfoundry.org/buildpacks/
Heroku : https://devcenter.heroku.com/articles/java-webapp-runner
Any application/ non spring apps which is plain war or jar can be used to run on PAAS platforms.

Discovering Hazelcast instance in a Spring Boot eco-system

Background:
We have a set of about 15 Spring Boot applications as microservices. They all run as Docker containers, and run as clusters of one or more instances. We also use Spring Cloud Netflix components such as Eureka and discover the running application instances from the client using Feign/Ribbon.
Question:
As part of the POC exercises, we tested with Redis and Hazelcast for caching and Spring Boot configuration storage. Everything works using Spring Boot, Spring Cloud and Redis/Hazelcast Java client libraries. However, when we deploy Hazelcast in a multi-node peer-to-peer cluster, Hazelcast seems to require a "known" IP address/hostname and the accessible port to be available in the Java client's configuration (with or without Spring). Typically, when Hazelcast is deployed in a multi-instance cluster on ephemeral VM instances (for example, EC2), the IP address and the port information is not available. So we thought of two possible solutions:
Find a way to run Hazelcast as a Spring Boot application, and register it with Eureka as a Discovery Client. That way other Spring Boot applications can use Eureka to discover an instance of Hazelcast dynamically
Find a way in Hazelcast so that it can publish it's IP address and port information dynamically to a central Key/Value store
If anyone has played around with Hazelcast to be able to do either/both of the possible solutions, it would be great if you can share more information on that. If there is a third approach that'd work better, I will be eager to know that as well.

Resources