gRPC-routing-using-Traefik-vs-NGINX

gRPC-routing using Træfik vs NGINX

Current Scenario

When developing a web-based software that has a shiny web UI, a set of APIs and is written in Go, you’re typically using the excellent gRPC standard to ensure maximum flexibility and performance.

Imagine the application is composed of various modules, each implemented as a different executable, each responsible for a different task.
All modules work together to compose the web application. A simple reverse proxy stands in front of the modules, choosing the correct one based on the URL prefix.

A different port is used for the gRPC interface. A simple setup, as you can see in this picture

NGINX

For the role of reverse proxy a common choice is NGINX: you simply can’t go wrong with NGINX and most admins know it.
Furthermore, it’s fast, powerful and can handle the TLS layer without issues.
So anybody can configure it, and it’s really great as a reverse proxy.

Issues

You could think, that the story is already over and NGINX was running fine for us. Not really…

In a typical enterprise environment, the only ports you want (or you’re allowed) to use are 80 (HTTP) and 443 (HTTPS). Everything else is mostly blocked by a firewall or a proxy and it can take months to be authorized to configure (if at all).
But, as gRPC is based on HTTP, why not we simply use port 80 and route gRPC requests to the gRPC module using the reverse proxy?

Let’s implement that! gRPC is based on HTTP2, actually, but that shouldn’t be a concern. NGINX speaks HTTP2 so let’s give it a try?
As always, the devil is in the details.
You can’t easily use the URI to route the requests, because the URI depends on the gRPC schema and that may collide with the previous statements.

Fortunately, there is another way: let’s use Træfik.

Enter Træfik

Træfik (you can find it here) is a reverse proxy especially designed for working as a router. Having a Cloud Native approach, it is well integrated and deployable with Kubernetes, Docker, and all container management systems.
It’s dynamically configurable and reliable. Like NGINX, it’s powerful, can handle the TLS layer and it’s very fast.

It also shines, more than NGINX, as it is designed to work in a 12-factor application (you can find more information here) and it can use different rules to route HTTP requests.
You can use the URI, but you can also use other information extracted from the request.

All gRPC requests have a content-type set to “application/grpc”. So it’s easy to write a rule for that (I’ll use Kubernetes dynamic configuration syntax):

- match: Headers(`content-type`,`application/grpc`) 
name: route2grpc
kind: Rule
priority: 50
services:
- name: grpc
port: 8080
scheme: h2c

That way, we can send the gRPC request to the correct backend (remember to use the h2c scheme), multiplexing the requests over a single HTTP (or HTTPS) port:

Træfik

So, switching from NGINX to Træfik allows a solution that’s compatible with enterprise settings, and it’s even easier to deploy.

CNIL Metrics & Logs

Self-Hosted performance monitoring and compliant log analysis for VMware vSphere, container and much more.

immudb

Built on the fastest immutable ledger technology. Open Source and easy to use and integrate into existing application.

Codenotary Cloud

Trusted CI/CD, SBOM and artifact
protection with cryptographic proof.
One CLI to manage all.

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.

Subscribe to our newsletter

Use Case - Tamper-resistant Clinical Trials

Goal:

Blockchain PoCs were unsuccessful due to complexity and lack of developers.

Still the goal of data immutability as well as client verification is a crucial. Furthermore, the system needs to be easy to use and operate (allowing backup, maintenance windows aso.).

Implementation:

immudb is running in different datacenters across the globe. All clinical trial information is stored in immudb either as transactions or the pdf documents as a whole.

Having that single source of truth with versioned, timestamped, and cryptographically verifiable records, enables a whole new way of transparency and trust.

Use Case - Finance

Goal:

Store the source data, the decision and the rule base for financial support from governments timestamped, verifiable.

A very important functionality is the ability to compare the historic decision (based on the past rulebase) with the rulebase at a different date. Fully cryptographic verifiable Time Travel queries are required to be able to achieve that comparison.

Implementation:

While the source data, rulebase and the documented decision are stored in verifiable Blobs in immudb, the transaction is stored using the relational layer of immudb.

That allows the use of immudb’s time travel capabilities to retrieve verified historic data and recalculate with the most recent rulebase.

Use Case - eCommerce and NFT marketplace

Goal:

No matter if it’s an eCommerce platform or NFT marketplace, the goals are similar:

  • High amount of transactions (potentially millions a second)
  • Ability to read and write multiple records within one transaction
  • prevent overwrite or updates on transactions
  • comply with regulations (PCI, GDPR, …)


Implementation:

immudb is typically scaled out using Hyperscaler (i. e. AWS, Google Cloud, Microsoft Azure) distributed across the Globe. Auditors are also distributed to track the verification proof over time. Additionally, the shop or marketplace applications store immudb cryptographic state information. That high level of integrity and tamper-evidence while maintaining a very high transaction speed is key for companies to chose immudb.

Use Case - IoT Sensor Data

Goal:

IoT sensor data received by devices collecting environment data needs to be stored locally in a cryptographically verifiable manner until the data is transferred to a central datacenter. The data integrity needs to be verifiable at any given point in time and while in transit.

Implementation:

immudb runs embedded on the IoT device itself and is consistently audited by external probes. The data transfer to audit is minimal and works even with minimum bandwidth and unreliable connections.

Whenever the IoT devices are connected to a high bandwidth, the data transfer happens to a data center (large immudb deployment) and the source and destination date integrity is fully verified.

Use Case - DevOps Evidence

Goal:

CI/CD and application build logs need to be stored auditable and tamper-evident.
A very high Performance is required as the system should not slow down any build process.
Scalability is key as billions of artifacts are expected within the next years.
Next to a possibility of integrity validation, data needs to be retrievable by pipeline job id or digital asset checksum.

Implementation:

As part of the CI/CD audit functionality, data is stored within immudb using the Key/Value functionality. Key is either the CI/CD job id (i. e. Jenkins or GitLab) or the checksum of the resulting build or container image.

White Paper — Registration

We will also send you the research paper
via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on CodeNotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.