Thread configuration in spring boot with embedded tomcat - java

I have spring boot application with embedded tomcat and Java melody configured to it using dependency in pom.xml.
I am doing performance testing for my application but problem is no matter how big load is i.e 30hits per second or 500hits per second. Number of threads in java melody in not going beyond 25-30.
Is their any default configuration in spring boot which is limiting the threads opening or any resources depend like memory or cpu ? I am not using any thread configuration in my application which means by default it will have 200 threads if i am not wrong.
Please suggest.
Note : I am running my application with 5gb memory and 2 vCPU.

Related

Is it possible/advisable to run Spring Boot without controllers just for the #ScheduledTasks and ORM?

I'd like to run a Spring Boot service without any of the controller-related stuff. I'd like it to just run a scheduled task every hour and do work if needed. I'm wanting to use Spring Boot, because I already know how to set the Hibernate ORM up, and I'm re-using a lot of the same repositories as another Spring Boot service. So, I spun up a new Spring Boot project and left out the start-web package.
The main issue I'm running into is that despite having a scheduled task set up, the service starts and immediately quits without running the scheduled task. In my head, I imagined the service kind of just sitting there, running, waiting for the time to trigger the scheduled job I have configured and kind of just sleeping until then. Are my expectations bad, or do I just have it misconfigured?
I've solved the problem. It was a configuration issue causing the Spring Boot app to not recognize the presence of required configuration values in the application.properties file.
You can either remove spring-boot-starter-web from your dependencies or in your main class you can configure the SpringApplicationBuilder to not include the web server.
new SpringApplicationBuilder(YourApplication.class)
.web(WebApplicationType.NONE)
.run(args);
Use #EnableScheduling in main class and application won't shuts down.

Spring Boot 2 how to change startup behaviour

do not judge this question) I want to implement WEB installer for my Spring Boot application, and very interesting moment is that my application plays 2 role: Installer and Backend(Application). When i first run my app i need to tell Spring to not initialize particular beans(Hibernate(while startup application must not to be failed to start because database may not exist), ActiveMq and others beans that will be added in installation process) and show some html pages with installation guide. Also i need to prevent access to endpoints where some logic with database occurs. When installation finished i will create new application.properties or some other file with settings and i tell Spring to initialize all required beans with Hibernate, ActiveMQ and others. Maybe i will make restart of application and new behaviour that based on installation will occur. And in next starts my application will not show installation guide. To simplify the question: I need to change startup behaviour of Spring Boot Application. For fun i can give an example with human: I need to make human live with no organs, and this human will live very good, and if i want i can add organs to human and he will be live very well))
You can use #Profile annotation. Check this link: https://www.mkyong.com/spring/spring-profiles-example/

Spring boot hot reload

I'm using spring boot and uses the fat jar for production, which is pretty cool.
However, the way I'm deploying forces the application to be shutdown for about 15 seconds when redeploying, because I have to kill the running jar and start the new one. I haven't found any solutions for this, i.e. how to reload the new jar without a restart.
Is it possible to "hot reload/replace" the jar or would I have to run in a container, like tomcat, and deploying a war?
Please note that it's in production so I guess dev-tools is out of question.
It's more infrastructure question I guess.
You can create second "reserve"instance running your app.
When you are updating your app on the main instance - all users requests must be redirected to the second "reserve" instance. When the redeploy is finished - you redirect the request to the main instance again. And then redeploy app on the reserve instance. For example Nginx may help you with those redirections.

Spring Boot setting up Active profiles in an environment

I have a couple of Linux Environments into which my spring boot application is going to be deployed i.e QA & PROD.
If I set a System property such as thsese and pull them in the Spring Boot app to set the active environments,
ENVIRONMENT=QA in QA and
ENVIRONMENT=PROD in PROD
are there any potential limitations (technicnal, administration, continuous integration issues etc.)that I might face or is there a better approach to pick up the active environment?
Just name your environment variable SPRING_PROFILES_ACTIVE and it will automatically get picked up by Spring Boot, no need to implement any custom logic for that (see the documentation about externalized configuration: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config).

Tomcat server - JBPM - Takes 3 hours to start

I'm trying to deploy the jBPM 6.1.0.Final version code using Spring on Tomcat 6.0 server. It is taking more than 3 hours to start the RuntimeManager when server starts. I have used below :
1) Spring integration
2) Added process and task lifecycle listeners
3) Used singleton session strategy
I am not sure why it is taking so much time to deploy. With JBPM 5.4 it worked just fine.
I have taken the thread dump and memory dump, but there is nothing out of the ordinary. Are there any other ways I can view exactly which threads are hogging the time?
EDIT - Java version 6, Tomcat version 6
So the issue has been identified. The bottle neck was with http://www.omg.org/spec/BPMN/20100524 namespace. There were several such namespaces included in the BPM XML file for XSD. But they weren't getting loaded. The root cause is an Eclipse plugin bug for BPMN2 plugin that generates incorrect XSD definitions in the XML file. By removing all XSD definitions except BPMN2.0.xsd it started correctly.

Categories