This assignment introduces Go, RESTful APIs, cloud deployment, and basic performance testing.
I implemented a simple backend service using the Gin Web Framework, deployed it to AWS EC2, and evaluated its performance under load.
- Implemented a RESTful API with endpoints:
GET /albums→ returns all albums as JSONPOST /albums→ adds a new album from JSON request bodyGET /albums/:id→ returns a specific album by ID
- Learned about:
go mod initand dependency management withgo get- Handlers, endpoints, and JSON serialization
- Difference between
localhostand0.0.0.0
- Created and configured an EC2 instance (Amazon Linux 2023,
t2.micro) - Steps:
- Generated SSH key pair (
rsa_pem.pem) - Connected via SSH:
ssh -i rsa_pem.pem ec2-user@<EC2_PUBLIC_IP>
- Cross-compiled Go program for Linux:
GOOS=linux GOARCH=amd64 go build -o server main.go
- Uploaded binary with
scpand ran on EC2
- Generated SSH key pair (
- Configured Security Group to open port
8080 - Verified deployment with:
curl http://<EC2_PUBLIC_IP>:8080/albums
- Wrote a Python script (load_test.py) to: Send continuous GET requests for 30s Collect response times Visualize results (histogram + scatter plot) Compute statistics (average, median, percentiles)
- Results: Average latency: ~65 ms Stable baseline, with a few slow outliers (>100 ms) Demonstrated long tail latency
- Insights: t2.micro has limited CPU → variability under load Tail latency grows worse with higher concurrency Network + server both contribute to delays
- Start EC2 instance
- SSH into instance:
ssh -i rsa_pem.pem ec2-user@<EC2_PUBLIC_IP>
- Run server:
./server
- Test SPI:
curl http://<EC2_PUBLIC_IP>:8080/albums
- main.go → Gin REST API code
- go.mod, go.sum → Go module files
- load_test.py → Python load testing script
- README.md → this file