Skip to content

Latest commit

 

History

History
110 lines (76 loc) · 1.84 KB

File metadata and controls

110 lines (76 loc) · 1.84 KB

High Performance Backend

A high-performance backend service built with Rust, gRPC, Redis, and PostgreSQL.

Features

  • Fast message processing with gRPC
  • Redis caching for improved performance
  • PostgreSQL persistence for data storage
  • Docker support for easy deployment
  • Async Rust for high concurrency

Prerequisites

  • Rust (latest stable version)
  • PostgreSQL
  • Redis
  • Docker and Docker Compose (for containerized deployment)
  • Protocol Buffers compiler (protoc)

Local Development Setup

  1. Install dependencies:
# For macOS
brew install postgresql redis protobuf
  1. Clone the repository:
git clone https://github.com/rikulauttia/gRPC-Redis-Postgres-Engine.git
cd gRPC-Redis-Postgres-Engine
  1. Set up environment variables:
# Create .env file
cp .env.example .env
# Edit .env with your configuration
  1. Run the database migrations:
cargo install sqlx-cli
sqlx migrate run
  1. Build and run the service:
cargo build
cargo run

Docker Deployment

  1. Build and start the containers:
docker compose up --build
  1. Stop the containers:
docker compose down

API Documentation

MessagingService

SendMessage

Sends a message to a specific user. Request (MessageRequest):

-user_id: string - Unique identifier of the user

-message: string - Content of the message

Response (MessageResponse):

-status: string - Status of the operation

Example using grpcurl:

grpcurl -d '{"user_id": "123", "message": "Hello"}' \
  -plaintext localhost:50051 \
  messaging.MessagingService/SendMessage

Performance Testing

Run performance tests using ghz:

ghz --insecure \
  --proto ./proto/service.proto \
  --call messaging.MessagingService.SendMessage \
  -d '{"user_id": "123", "message": "test"}' \
  -n 1000 \
  -c 50 \
  '[::1]:50051'