AWS › Core Services Overview
How should a beginner decide between using a serverless service like Lambda versus a traditional compute service like EC2 for a new application?
IntermediateAnswer
The decision typically depends on factors such as how predictable and consistent your workload is, with Lambda being well suited for event driven, intermittent, or unpredictable workloads since you only pay for actual execution time, while EC2 makes more sense for long running, steady state applications, workloads requiring specific operating system level control, or applications that need to maintain persistent in memory state across requests that a stateless Lambda function cannot easily provide.
// Lambda: good fit for infrequent, event driven processing
// EC2: good fit for a continuously running web server with steady trafficReal-world example A developer building an infrequently used image processing function that only runs when a new file is uploaded chooses Lambda for its pay per use pricing, while choosing EC2 for their continuously running, steady traffic main web application.