A high-performance web API built with D language using the vibe.d framework, featuring multi-threading support and Nginx load balancing.
- RESTful API endpoints
- Multi-threaded architecture
- Nginx load balancing
- Docker containerization
- Performance stress testing with k6
Before running the application, ensure you have the following installed:
- D compiler (dmd)
- DUB package manager
- Docker and Docker Compose
- Required system libraries
- Install system dependencies:
sudo apt-get update
sudo apt-get install -y libssl-dev libevent-dev zlib1g-dev- Install D compiler and DUB:
sudo apt install dub
curl -fsS https://dlang.org/install.sh | bash -s dmd
source ~/dlang/dmd-2.111.0/activateTo run the application locally:
dub clean
dub upgrade
dub runThe API will be available at: http://localhost:8081
To run the application with Docker:
docker-compose down
docker-compose build --no-cache
docker-compose upThe API will be available at: http://localhost
- `GET /` - Returns status message
- Response: `{"status": "running ..."}`
- `GET /run` - Returns success message
- Response: `{"message": "everything is working"}`curl -X POST http://localhost:8081/users/random
curl http://localhost:8081/users/1
curl "http://localhost:8081/users?limit=10&offset=0"
curl -X PUT http://localhost:8081/users/1 \
-H "Content-Type: application/json" \
-d '{
"username": "newusername",
"email": "newemail@example.com",
"age": 25,
"country": "Canada"
}'
curl -X DELETE http://localhost:8081/users/1The project includes k6 stress testing configuration. To run the tests:
# Start the application
docker-compose up -d app nginx
# Run stress tests
docker-compose exec k6 /bin/sh
docker-compose run k6 run /scripts/load-test.js
docker-compose run k6 run /scripts/stress-test.jsThe stress test will:
- Start with 20 virtual users
- Gradually increase to 50 users
- Then to 100 users
- Finally ramp down to 0
The application uses:
- D language with vibe.d framework
- Nginx for load balancing
- Docker for containerization
- k6 for performance testing
- GET / - Root endpoint
- GET /run - Test endpoint
- GET /time - Time endpoint with random delay
- POST /upload - File upload endpoint
- POST /users/random - Create random user
- GET /users/:id - Get user by ID
- GET /users - List users with pagination
- PUT /users/:id - Update user
- DELETE /users/:id - Delete user