A high-performance backend service built with Rust, gRPC, Redis, and PostgreSQL.
- 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
- Rust (latest stable version)
- PostgreSQL
- Redis
- Docker and Docker Compose (for containerized deployment)
- Protocol Buffers compiler (protoc)
- Install dependencies:
# For macOS
brew install postgresql redis protobuf
- Clone the repository:
git clone https://github.com/rikulauttia/gRPC-Redis-Postgres-Engine.git
cd gRPC-Redis-Postgres-Engine
- Set up environment variables:
# Create .env file
cp .env.example .env
# Edit .env with your configuration
- Run the database migrations:
cargo install sqlx-cli
sqlx migrate run
- Build and run the service:
cargo build
cargo run
- Build and start the containers:
docker compose up --build
- Stop the containers:
docker compose down
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
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'