pinterest/jbender

Name: jbender

Owner: Pinterest

Description: An easy-to-use library for creating load testing applications.

Created: 2015-10-31 03:20:59.0

Updated: 2018-05-11 08:18:48.0

Pushed: 2016-08-03 22:10:35.0

Homepage: null

Size: 163

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

JBender

Build Status

JBender makes it easy to build load testers for services using protocols like HTTP and Thrift (and many others). JBender provides a library of flexible, easy-to-use primitives that can be combined (with plain Java code) to build high performance load testers customized to any use case, and that can evolve with your service over time.

JBender provides two different approaches to load testing. The first, JBender.loadTestThroughput gives the tester control over the throughput (queries per second), but not over the concurrency (number of active connections). This approach is well suited for services that are open to the Internet, like web services, and the backend services to which they speak. The primary benefit of this approach is that the load tester will maintain the requested throughput, even if the service is struggling (or failing) to support it. As a result, a much more clear picture of how the target service responds to load is provided.

The second approach, JBender.loadTestConcurrency, gives the tester control over the concurrency (number of active connections), but not the throughput (queries per second). This approach is well suited to applications that need to test a large number of concurrent, inactive connections, like chat servers. This approach is not suitable for testing request latency, as the load tester will slow down to match the server (because it cannot start more connections than requested).

That JBender is a library makes it flexible and easy to extend, but means it takes longer to create an initial load tester. As a result, we've focused on creating easy-to-follow tutorials.

Quasar

The JBender library makes heavy use of Quasar, a library from Parallel Universe which adds lightweight threads (called “fibers”) to the JVM.

The tutorials, linked below, will help you get up and running with Quasar and JBender, and provide some background on how Quasar works (hint: it's very straightforward to use Quasar!). Here are some links for more information:

Getting Started

The easiest way to get started with JBender is to use one of the tutorials:

Performance

The Linux TCP stack for a default server installation is usually not tuned to high throughput servers or load testers. After some experimentation, we have settled on adding these lines to /etc/sysctl.conf, after which you can run sysctl -p to load them (although it is recommended to restart your host at this point to make sure these take effect).

tc/sysctl.conf
crease system file descriptor limit
ile-max = 100000

crease ephermeral IP ports
ipv4.ip_local_port_range = 1024 65000

crease Linux autotuning TCP buffer limits
t max to 16MB for 1GE and 32M (33554432) or 54M (56623104) for 10GE
n't set tcp_mem itself! Let the kernel scale it based on RAM.
core.rmem_max = 16777216
core.wmem_max = 16777216
core.rmem_default = 16777216
core.wmem_default = 16777216
core.optmem_max = 40960
ipv4.tcp_rmem = 4096 87380 16777216
ipv4.tcp_wmem = 4096 65536 16777216

ke room for more TIME_WAIT sockets due to more clients,
d allow them to be reused if we run out of sockets
so increase the max packet backlog
core.netdev_max_backlog = 100000
ipv4.tcp_max_syn_backlog = 100000
ipv4.tcp_max_tw_buckets = 2000000
ipv4.tcp_tw_reuse = 1
ipv4.tcp_tw_recycle = 1
ipv4.tcp_fin_timeout = 10

sable TCP slow start on idle connections
ipv4.tcp_slow_start_after_idle = 0

om https://people.redhat.com/alikins/system_tuning.html
ipv4.tcp_sack = 0
ipv4.tcp_timestamps = 1

This is a slightly modified version of advice taken from this source: http://www.nateware.com/linux-network-tuning-for-2013.html#.VBjahC5dVyE

In addition, it helps to increase the open file limit with something like:

hat Is Missing

der does not provide any support for sending load from more than one machine. If you need to
 more load than a single machine can handle, or you need the requests to come from multiple
ical hosts (or different networks, or whatever), you currently have to write your own tools. In
tion, the histogram implementation used by JBender is inefficient to send over the network,
ke q-digest or t-digest, which we hope to implement in the future.

der does not provide any visualization tools, and has a relatively simple set of measurements,
uding a customizable histogram of latencies, an error rate and some other summary statistics.
der does provide a complete log of everything that happens during a load test, so you can use
ting tools to graph any aspect of that data, but nothing in JBender makes that easier right now.

der only provides helper functions for HTTP and Thrift currently, because that is all we use
rnally at Pinterest.

load testers we have written internally with JBender have a lot of common command line arguments,
we haven't finalized a set to share as part of the library.

omparison to Other Load Testers

 Bender

der is a port of Bender to the JVM platform with [Quasar](http://docs.paralleluniverse.co/quasar/)
tweight threads (_fibers_) and channels.

 JMeter

er provides a GUI to configure and run load tests, and can also be configured via XML (really,
ly not recommended by hand!) and run from the command line. JMeter's is not a good approach to
 testing services (see the JBender docs and the Iago philosophy for more details on why that is).
sn't easy to extend JMeter to handle new protocols, so it doesn't have support for Thrift or
obuf. It is relatively easy to extend other parts of JMeter by writing Java code, however, and
GUI makes it easy to plug all the pieces together.

 Iago

 is Twitter's load testing library and it is the inspiration for JBender's `loadTestThroughput`
tion. Iago is a Scala library written on top of Netty and the Twitter Finagle libraries. As a
lt, Iago is powerful, but difficult to understand, extend and configure. It was frustration with
ng Iago work that led to the creation of JBender.

 The Grinder

Grinder has the same load testing approach as JMeter, but allows scripting via Jython, which
s it more flexible and extensible. The Grinder uses threads, which limits the concurrency at
h it can work, and makes it hard to implement things like JBender's `loadTestThroughput` function.
Grinder does have support for conveniently running distributed load tests.

opyright

right 2015 Pinterest.com

nsed under the Apache License, Version 2.0 (the "License");
may not use this file except in compliance with the License.
may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

ss required by applicable law or agreed to in writing, software
ributed under the License is distributed on an "AS IS" BASIS,
OUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
the License for the specific language governing permissions and
tations under the License.

ttribution

der includes open source from the following sources:

ache Thrift Libraries. Copyright 2014 Apache Software Foundation. Licensed under the Apache License v2.0 (http://www.apache.org/licenses/).
asar Libraries. Copyright 2014 Parallel Universe. Licensed under the GNU Lesser General Public License (http://www.gnu.org/licenses/lgpl.html).

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.