Skip to content

Jotschi/vertx-c10k-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Vert.x C10K

This example project contains a very basic http server which demonstrates the basics that are need to build a Vert.x server which can handle 10k concurrent connections.

Test Server

The example program starts Vert.x and deploys multiple http verticles.

Noteworthy aspects:

  • The netty-transport-native-epoll library adds epoll support.

  • HttpServer options improve connection handling

options
    .setPort(SERVER_PORT)
    .setHost(SERVER_HOST)
    .setCompressionSupported(true)
    .setHandle100ContinueAutomatically(true)
    .setTcpFastOpen(true)
    .setTcpNoDelay(true)
    .setTcpQuickAck(true);
  • VertxOptions to prefer native transports
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setPreferNativeTransport(true);
  • Deploy multiple verticles
DeploymentOptions options = new DeploymentOptions();
int nVerticles = Runtime.getRuntime().availableProcessors() * 2;
options.setInstances(nVerticles);

Build & Run

mvn clean package
java -jar target/vertx-c10k-example-0.0.1-SNAPSHOT.jar

API Endpoints

Metrics

Kernel Options

# Increase amount of open files. This will allow the creation of more network sockets.
sysctl -w fs.file-max=110000
sysctl -w fs.nr_open=110000
ulimit -n 110000

# Increase tcp buffers
sysctl -w net.ipv4.tcp_mem="100000000 100000000 100000000"

# Increase socket connection limit
sysctl -w net.core.somaxconn=10000

# Increase backlog size for tcp connections in SYN state
sysctl -w net.ipv4.tcp_max_syn_backlog=10000

Tests

via wrk

./wrk -c10000 -d32s -t16 http://localhost:8080/static/4k

via apache benchmark

ab -n 200000 -c 10000 http://localhost:8080/static/4k

Example Results

  • On Intel i7 7700k @ Debian Linux 5.10.0-8-amd64
  • OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2)
# wrk -c10000 -d32s -t16 http://localhost:8080/static/4k
Running 32s test @ http://localhost:8080/static/4k
  16 threads and 10000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    99.31ms   46.74ms 435.93ms   68.46%
    Req/Sec     6.37k   578.54    20.15k    75.24%
  3247189 requests in 32.10s, 12.51GB read
Requests/sec: 101156.41
Transfer/sec:    399.10MB

Disclaimer

Please note that the results should not be used as a performance reference. The server response is static. The tests are run locally. There are many other factors which will affect real world performance.

Resources

About

Example Vert.x server which can handle C10K

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages