What is serverless computing and how does it relate to Spring Boot?
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
Serverless means the provider manages runtime provisioning and scaling while I deploy code or an image and configure events, permissions, limits, and resources. Servers still exist; they are outside the application's provisioning responsibility. Billing can include requests, execution duration, memory, provisioned concurrency, storage, logging, and networking.
For a Spring workload, an event such as an object upload can invoke a Spring Cloud Function adapter. A cold execution may need to initialize the runtime, JVM, framework, and connections, adding latency. A native image, smaller dependency graph, snapshot/restore feature, or provisioned concurrency may help, but the effect and price must be measured.
Serverless fits bursty event work and teams that accept platform limits. It may fit an HTTP API too; it is not automatically unsuitable. I compare latency distribution, concurrency limits, execution duration, state, integrations, observability, portability, and total cost rather than promising zero idle cost or fixed millisecond startup.
What is serverless computing and how does it relate to Spring Boot
Direct Answer
Serverless is a provider-managed execution model in which the platform provisions and scales runtime capacity while you deploy code or a container and configure events/resources. Billing may use requests, execution duration, memory, or provisioned capacity—not always only active milliseconds. Spring workloads can use Spring Cloud Function, adapted Spring Boot applications, containers, or native images; startup and runtime trade-offs must be measured.
Code Example
// Spring Cloud Function handler for AWS Lambda
@SpringBootApplication
public class OrderProcessorFunction {
@Bean
public Function<OrderEvent, OrderResult> processOrder() {
return event -> {
// Lambda invokes this function for each event
var orderId = event.orderId();
var items = event.items();
// Business logic runs without managing servers
double total = items.stream().map(Item::price).reduce(0.0, Double::sum);
return new OrderResult(orderId, total, "PROCESSED");
};
}
}
record OrderEvent(String orderId, List<Item> items) {}
record Item(String name, double price) {}
record OrderResult(String orderId, double total, String status) {}
Common Mistakes & Pitfalls
- Putting everything in Lambda: Freshers hear serverless is the future and migrate entire Spring Boot monoliths to Lambda, then face massive cold start delays and timeout errors because initialization takes longer than the 30-second Lambda limit.
- Ignoring memory-CPU coupling: Lambda doesn't let you choose CPU separately—allocating 512 MB memory gives you proportionally less CPU than 2048 MB, so under-allocating memory makes functions slow even after warm start.
- Not understanding cold start triggers: thinking once a function is warm it stays warm forever, when Lambda actually terminates idle containers according to provider-controlled reuse and scaling behavior, causing cold starts during low-traffic periods.
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.