A web server receives requests from customers or applications and returns web content or application responses. In a web shop, it handles customer requests while a database stores products and orders. On AWS, the server software can run on an EC2 virtual machine. section 1.2.1
To serve a default Apache website from an EC2 instance:
- Launch an Amazon Linux 2 instance and allow HTTP traffic from the internet. section 3.5
- Connect with Session Manager, then run `sudo yum install httpd -y`, `sudo systemctl start httpd`, and `sudo systemctl enable httpd`. section 3.5
- Find the instance’s public IPv4 address in the EC2 console and open `http://$PublicIp` in a browser to check the default site. section 3.5
One instance is useful for a first deployment, but its public IPv4 address can change when the instance stops and starts. A load balancer gives clients a target to request without knowing a particular server’s address. It can check server health and forward requests to healthy instances; running servers in different data centers improves availability because an individual virtual machine is not highly available by default. section 3.5 section 1.2.3 section 14.0
A web server for image processing
A Node.js server built with Express provides a REST API: `POST /image` creates a process, `GET /image/:id` returns its state, and `POST /image/:id/upload` accepts an upload. Multiple EC2 instances run the server behind a load balancer, while separate workers process images. This keeps request handling distinct from the processing work. section 16.3.2
A web server need not deliver every asset itself. For a web shop, moving static content such as a logo to a content delivery network reduces server load, while the servers continue handling dynamic content such as products and prices. section 1.2.1
Listing 16.2 Creating an image process with POST /image
app.post('/image', function(request, response) { #1
const id = uuidv4(); #2
db.putItem({ #3
'Item': {
'id': {
'S': id #4
},
'version': {
'N': '0' #5
},
'created': {
'N': Date.now().toString() #6
},
'state': {
'S': 'created' #7
}
},
'TableName': 'imagery-image', #8
'ConditionExpression': 'attribute_not_exists(id)' #9
}, function(err, data) {
if (err) {
throw err;
} else {
response.json({'id': id, 'state': 'created'}); #10
}
});
});
The Express route shows a concrete server response: `POST /image` writes a new process to DynamoDB and returns its ID and state as JSON. section 16.3.2










