8000 GitHub - roshandelpoor/D-Language-Web-API: D Language Web API with Multi-threading
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

roshandelpoor/D-Language-Web-API

Repository files navigation

D Language Web API with Multi-threading

A high-performance web API built with D language using the vibe.d framework, featuring multi-threading support and Nginx load balancing.

Features

  • RESTful API endpoints
  • Multi-threaded architecture
  • Nginx load balancing
  • Docker containerization
  • Performance stress testing with k6

Prerequisites

Before running the application, ensure you have the following installed:

  • D compiler (dmd)
  • DUB package manager
  • Docker and Docker Compose
  • Required system libraries

Installation

  1. Install system dependencies:
sudo apt-get update
sudo apt-get install -y libssl-dev libevent-dev zlib1g-dev
  1. 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/activate

Running the Application

Local Development

To run the application locally:

dub clean
dub upgrade
dub run

The API will be available at: http://localhost:8081

Docker Deployment

To run the application with Docker:

docker-compose down
docker-compose build --no-cache
docker-compose up

The API will be available at: http://localhost

API Endpoints

- `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/1

Performance Testing

The 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.js

Test Parameters

The stress test will:

  • Start with 20 virtual users
  • Gradually increase to 50 users
  • Then to 100 users
  • Finally ramp down to 0

Architecture

The application uses:

  • D language with vibe.d framework
  • Nginx for load balancing
  • Docker for containerization
  • k6 for performance testing

About

D Language Web API with Multi-threading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0