REST endpoints for user management:
- POST /users - Create a new user.
- GET /users/{id} - Retrieve user details by ID.
- PUT /users/{id} - Update user information by ID.
- DELETE /users/{id} - Delete a user by ID.
- GET /users - List all users with pagination.
Repository: https://github.com/bmcszk/user-service
- Docker
- Docker Compose
- Git
- Goland v1.23 or higher
- Make
- (optional) Kubectl
make compose- starts the docker compose environmentmake test- runs tests using composemake coverage- creates coverage reportmake kind-up tilt-up- starts local Kind k8s cluster and Tilt deployment
make sqlc- generates code using sqlcmake migrate-up- runs migrations upmake migrate-down- runs migrations down
- Simple project structure, directories:
- sources:
db- database layerapi- api layerlogic- business logic layere2e- end-to-end tests
- configs:
helm- helm chartstilt- tilt configs
- Simplest http layer using standard library
- Database is Postgres
- Simplest db layer using standard library and SQLC for code generation.
- Migrations handled automatically using Golang Migrate
- Deployment can be managed by Helm
- Local dev environment can be managed by Tilt
- CI is done using Github Actions where Kind cluster is created and Tilt is deployed. Check: https://github.com/bmcszk/user-service/actions/runs/11915468146/job/33205800016
- User model is very basic but with possibility to add more fields through DB migrations
- No authentication, no authorization
- Many TODOs in code
- Application can easily scaled using K8s manual and automatical scaling. Database can easily scaled using Cloud Native Postgres
- Designing the system to be able to handle 30k requests per minute with a latency of < 100ms. Step by step:
- Prepare configurable e2e test scenario running with up to 30k requests per minute.
- Prepare configuration and middlewares for telemetry, to monitor performance and latency of application and DB.
- Prepare test K8s cluster and deploy the application with DB.
- Run the e2e test scenario with small amount of requests per minute.
- Monitor the performance and latency of the application and DB.
- Gradually increase the number of requests per minute and monitor the performance and latency of the application and DB.
- Identify bottlenecks and adjust resources configuration, adjust number of instances of the application and DB.
- Go to step 5. until reaching the desired performance and latency.