0
0
Spring Bootframework~8 mins

Embedded server concept in Spring Boot - Performance & Optimization

Choose your learning style9 modes available
Performance: Embedded server concept
MEDIUM IMPACT
This concept affects the application startup time and runtime resource usage by bundling the server inside the app.
Running a Spring Boot application with an embedded server versus deploying to an external server
Spring Boot
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args); // Embedded Tomcat starts automatically
    }
}

// Application packaged as executable JAR with embedded Tomcat server
Embedded server starts with the app, reducing deployment steps and improving startup consistency.
📈 Performance GainReduces deployment complexity and can improve startup time by avoiding external server boot
Running a Spring Boot application with an embedded server versus deploying to an external server
Spring Boot
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DemoApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

// Application packaged as a WAR and deployed to an external Tomcat server
Deploying as WAR to an external server requires separate server setup and can delay startup due to server initialization overhead.
📉 Performance CostBlocks startup for several seconds due to external server boot and app deployment
Performance Comparison
PatternStartup TimeMemory UsageDeployment ComplexityVerdict
External server deployment (WAR)Higher (5-10s+)Lower (server shared)Higher (server setup needed)[! ] OK
Embedded server deployment (executable JAR)Lower (2-5s)Higher (server bundled)Lower (self-contained)[OK] Good
Rendering Pipeline
The embedded server concept impacts the backend startup and runtime environment rather than browser rendering directly. It affects how fast the server is ready to respond to requests, influencing the Largest Contentful Paint (LCP) indirectly by server response time.
Server Startup
Application Initialization
Request Handling
⚠️ BottleneckServer Startup time due to embedded server initialization
Core Web Vital Affected
LCP
This concept affects the application startup time and runtime resource usage by bundling the server inside the app.
Optimization Tips
1Embedded servers reduce deployment complexity by bundling server and app.
2Startup time may increase slightly due to server initialization inside the app.
3Monitor startup logs and JVM metrics to optimize embedded server performance.
Performance Quiz - 3 Questions
Test your performance knowledge
How does using an embedded server in Spring Boot affect application startup time compared to deploying on an external server?
AIt increases startup time because the server must start separately
BIt has no effect on startup time
CIt generally reduces startup time by bundling server and app together
DIt delays startup due to network overhead
DevTools: Spring Boot Actuator and JVM monitoring tools
How to check: Enable Spring Boot Actuator endpoints and monitor startup logs; use JVM tools like VisualVM to check memory and CPU usage during startup
What to look for: Look for server startup time in logs and memory footprint; faster startup and stable memory indicate good embedded server performance