Skip to content

High-Performance Rust Backend using Rust, gRPC, Redis, and PostgreSQL. This project focuses on creating a scalable backend system capable of handling millions of requests per second, ideal for applications like messaging services or social network feeds.

Notifications You must be signed in to change notification settings

rikulauttia/gRPC-Redis-Postgres-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

About

High-Performance Rust Backend using Rust, gRPC, Redis, and PostgreSQL. This project focuses on creating a scalable backend system capable of handling millions of requests per second, ideal for applications like messaging services or social network feeds.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published