Open Source API Gateway

Java API Gateways

Java API Gateways combine high performance with a broad feature set and excellent integration capabilities. They are often faster in real workloads than expected and benefit from the rich Java ecosystem.

This article explains what a Java API Gateway is, why it is special, and what its limitations are.

What Is a Java API Gateway?

A Java API Gateway is an API gateway built entirely in Java, leveraging the countless libraries of the Java ecosystem. Unlike gateways based on Nginx that use embedded scripting engines for plugins and API functionality, a Java gateway is homogeneously implemented in Java. All components of a Java gateway from the HTTP protocol to OpenAPI validators are made with Java. This unified approach makes a gateway easy to extend, debug, and integrate with enterprise infrastructure. It also allows developers to configure and adapt core behavior without switching between languages or runtimes.

Well-known Java API gateways include Gravitee, Membrane, Apigee, and Spring Cloud Gateway.

Why Choose a Java API Gateway?

Java provides a mature platform and a vast ecosystem of libraries. Many gateway features can be implemented simply by wrapping battle-tested Java libraries as plugins. This approach is typically faster and less error-prone than writing Lua scripts for a C-based reverse proxy such as Nginx.

Over the last 15+ years, gateways from multiple vendors have proven that Java is both reliable and performant in production.

A key advantage is integration of legacy technologies such as SOAP, WSDL and XML. Large organizations still rely on XML and SOAP-based Web Services, and Java offers a wealth of libraries for handling them. This makes it straightforward for Java API gateways to provide strong support for XML processing and Web Services integration.

Advantages of a Java API Gateway

  • Easy extensibility with Java or Groovy; you do not have to learn Lua to configure an API
  • Leverages the rich Java ecosystem (security, JSON/XML, observability, testing) and integrates well with enterprise Java applications
  • Excellent legacy integration (SOAP, WSDL, XML)
  • Embeddable into custom Java applications

Performance & Resource Use

Java Gateways Are Almost as Fast as Gateways Written in Go or Rust

A gateway’s CPU time is split between user time and system time. User time is spent running the gateway’s code; system time is spent by the operating system handling tasks such as network input and output. Unlike image editing or video rendering, API gateways do relatively little computation and a lot of input and output.

For a typical API gateway, system time accounts for about 70 to 80% of CPU time, with the rest spent executing Java code. Replacing Java with a faster language cannot eliminate the time the operating system spends handling network traffic. That limits the gains: even if the gateway’s own code took no time to run, the overall speedup would be limited. Gateways written in faster languages may be at most 20 to 40% faster than an optimized Java implementation.

Java Gateways Stay Fast in Realistic Setups

Java gateways remain fast with API features such as OpenAPI validation and JSON transformation enabled. Plugins can reduce throughput severalfold, so realistic setups provide a more useful comparison than forwarding-only benchmarks.

With features enabled, Java-based gateways often outperform solutions that combine native code with interpreted scripts. Plugins written in another language, such as Lua, add cross-runtime overhead. A gateway built on a single platform, such as Java, avoids that overhead and can deliver higher throughput.

Memory Footprint

A higher memory footprint is the trade-off for Java’s ecosystem and extensibility. Typical Java gateways, e.g., Membrane, need 200–400 MByte for operation. If you deploy hundreds of sidecar micro-gateways, this may be too much overhead, but for a few central gateways it’s negligible.

Native image compilation (e.g., GraalVM) can further reduce startup and memory in specific scenarios.

Don’t Java’s Garbage Collection Pauses Cause Latency Problems?

Java has automatic memory management that makes it very stable and avoids crashes. To free memory, garbage collections must be executed. While unused objects are collected, the Java VM can pause and cause latency.

Garbage collection was a problem decades ago, but modern Java has solved it, so we get the advantages of a GC without paying a significant price.

As measurements show: Garbage collection has practically no effect on a Java API Gateways response times. At 1,000 requests per second, 999 out of 1,000 requests were answered in under one millisecond. Garbage collection briefly delayed about 2 in 3,000 requests, each by around one millisecond.1

FAQ

Question: Can I run a Java API Gateway in Docker?
Answer: Yes. Java gateways run well in containers. Image size and memory usage are manageable for most deployments.

Question: What is the best deployment option for a Java API Gateway?

Answer: There is no single preferred option. A Java API Gateway can run in a container, directly on the Java Virtual Machine, inside a Java web server such as Tomcat, in an OSGi runtime, or on operating systems including Linux, Windows, and macOS.

Question: How do I extend a Java gateway?
Answer: You can extend a Java gateway with Java or JVM languages such as Groovy, or by using expression languages. See the documentation for examples.

Try a Java Gateway

Membrane API Gateway is a Java-based gateway with OpenAPI validation and legacy XML/SOAP support.

Start with the Quick Start and discover the potential of Java API Gateways, even when running in a Docker container.

Footnotes

  1. Measured on 21 October 2026 with Membrane API Gateway on three cloud servers (one load generator, one gateway, one backend). The gateway forwarded 300,000 requests over five minutes at a steady 1,000 requests per second, using Java 21, its default garbage collector (G1) and 250 MB of memory. The gateway's garbage collection briefly paused it about once every 1.4 seconds, usually for 1 to 3 milliseconds. Requests that arrived during such a pause were delayed by about one millisecond. With the low-pause collectors ZGC and Shenandoah, no request was delayed by garbage collection, at the cost of more processor time: about 2 % of one core for ZGC. Details: distribution/performance-test/RESULTS.md, section "Typical load".

Java is a registered trademark of Oracle and/or its affiliates. Membrane API Gateway is an open-source project by predic8 and is not affiliated with, endorsed by, or sponsored by Oracle.