Skip to content

Instantly share code, notes, and snippets.

@elyograg
Last active March 25, 2018 15:23
Show Gist options
  • Save elyograg/abedf4ae28467059e46781f7d474f379 to your computer and use it in GitHub Desktop.
Save elyograg/abedf4ae28467059e46781f7d474f379 to your computer and use it in GitHub Desktop.
SolrJ benchmark
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
At least one thread has done 0 queries.
At least one thread has done 100 queries.
At least one thread has done 200 queries.
At least one thread has done 300 queries.
At least one thread has done 400 queries.
At least one thread has done 500 queries.
At least one thread has done 600 queries.
At least one thread has done 700 queries.
At least one thread has done 800 queries.
At least one thread has done 900 queries.
query count: 100000
elapsed count: 100000
query median: 218.0
elapsed median: 236.0
query 75th: 305.0
elapsed 75th: 325.0
query 95th: 471.0
elapsed 95th: 498.0
query 99th: 616.0
elapsed 99th: 654.01
total time in seconds: 260
numThreads: 100
queries per thread: 1000
qps: 384
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
At least one thread has done 0 queries.
At least one thread has done 100 queries.
At least one thread has done 200 queries.
At least one thread has done 300 queries.
At least one thread has done 400 queries.
At least one thread has done 500 queries.
At least one thread has done 600 queries.
At least one thread has done 700 queries.
At least one thread has done 800 queries.
At least one thread has done 900 queries.
query count: 10000
elapsed count: 10000
query median: 17.0
elapsed median: 23.0
query 75th: 20.0
elapsed 75th: 26.0
query 95th: 26.0
elapsed 95th: 34.0
query 99th: 109.0
elapsed 99th: 116.0
total time in seconds: 26
numThreads: 10
queries per thread: 1000
qps: 384
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
At least one thread has done 0 queries.
At least one thread has done 100 queries.
At least one thread has done 200 queries.
At least one thread has done 300 queries.
At least one thread has done 400 queries.
At least one thread has done 500 queries.
At least one thread has done 600 queries.
At least one thread has done 700 queries.
At least one thread has done 800 queries.
At least one thread has done 900 queries.
query count: 200000
elapsed count: 200000
query median: 470.0
elapsed median: 498.0
query 75th: 653.0
elapsed 75th: 685.0
query 95th: 995.0
elapsed 95th: 1036.0
query 99th: 1297.0
elapsed 99th: 1355.0
total time in seconds: 544
numThreads: 200
queries per thread: 1000
qps: 367
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
At least one thread has done 0 queries.
At least one thread has done 100 queries.
At least one thread has done 200 queries.
At least one thread has done 300 queries.
At least one thread has done 400 queries.
At least one thread has done 500 queries.
At least one thread has done 600 queries.
At least one thread has done 700 queries.
At least one thread has done 800 queries.
At least one thread has done 900 queries.
query count: 20000
elapsed count: 20000
query median: 35.0
elapsed median: 46.0
query 75th: 43.0
elapsed 75th: 55.0
query 95th: 94.0
elapsed 95th: 112.0
query 99th: 126.0
elapsed 99th: 142.0
total time in seconds: 52
numThreads: 20
queries per thread: 1000
qps: 384
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
At least one thread has done 0 queries.
At least one thread has done 100 queries.
At least one thread has done 200 queries.
At least one thread has done 300 queries.
At least one thread has done 400 queries.
At least one thread has done 500 queries.
At least one thread has done 600 queries.
At least one thread has done 700 queries.
At least one thread has done 800 queries.
At least one thread has done 900 queries.
query count: 2000
elapsed count: 2000
query median: 9.0
elapsed median: 11.0
query 75th: 9.0
elapsed 75th: 12.0
query 95th: 11.0
elapsed 95th: 14.0
query 99th: 60.02
elapsed 99th: 95.04
total time in seconds: 14
numThreads: 2
queries per thread: 1000
qps: 142
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
At least one thread has done 0 queries.
At least one thread has done 100 queries.
At least one thread has done 200 queries.
At least one thread has done 300 queries.
At least one thread has done 400 queries.
At least one thread has done 500 queries.
At least one thread has done 600 queries.
At least one thread has done 700 queries.
At least one thread has done 800 queries.
At least one thread has done 900 queries.
query count: 5000
elapsed count: 5000
query median: 11.0
elapsed median: 15.0
query 75th: 12.0
elapsed 75th: 16.0
query 95th: 17.0
elapsed 95th: 21.0
query 99th: 60.01
elapsed 99th: 103.0
total time in seconds: 18
numThreads: 5
queries per thread: 1000
qps: 277
package foobar;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
import com.google.common.math.Quantiles;
public class SolrFun
{
private static final String SOLR_URL = "http://idxa1.REDACTED.com:8981/solr";
private static final String SOLR_CORE = "ncmain";
private static final int NUM_THREADS = 100;
private static final int QUERIES_PER_THREAD = 1000;
private static final List<Integer> queryTimes = Collections.synchronizedList(new ArrayList<>());
private static final List<Integer> elapsedTimes = Collections
.synchronizedList(new ArrayList<>());
public static void main(String[] args) throws InterruptedException
{
List<Thread> workers = new ArrayList<>();
QueryWorker.init();
for (int i = 0; i < NUM_THREADS; i++)
{
Thread t = new QueryWorker();
t.setName("QW" + i);
workers.add(t);
}
long start = System.nanoTime();
for (Thread t : workers)
{
t.start();
}
boolean running = true;
while (running)
{
running = false;
for (Thread t : workers)
{
if (t.isAlive())
{
running = true;
}
}
Thread.sleep(100);
}
long elapsed = (System.nanoTime() - start) / 1000000;
long qps = queryTimes.size()/(elapsed/1000);
System.out.println("");
System.out.println("query count: " + queryTimes.size());
System.out.println("elapsed count: " + elapsedTimes.size());
double qtMedian = Quantiles.median().compute(queryTimes);
double elMedian = Quantiles.median().compute(elapsedTimes);
double qt75 = Quantiles.percentiles().index(75).compute(queryTimes);
double el75 = Quantiles.percentiles().index(75).compute(elapsedTimes);
double qt95 = Quantiles.percentiles().index(95).compute(queryTimes);
double el95 = Quantiles.percentiles().index(95).compute(elapsedTimes);
double qt99 = Quantiles.percentiles().index(99).compute(queryTimes);
double el99 = Quantiles.percentiles().index(99).compute(elapsedTimes);
System.out.println("query median: " + qtMedian);
System.out.println("elapsed median: " + elMedian);
System.out.println("query 75th: " + qt75);
System.out.println("elapsed 75th: " + el75);
System.out.println("query 95th: " + qt95);
System.out.println("elapsed 95th: " + el95);
System.out.println("query 99th: " + qt99);
System.out.println("elapsed 99th: " + el99);
System.out.println("total time in seconds: " + elapsed / 1000);
System.out.println("numThreads: " + NUM_THREADS);
System.out.println("queries per thread: " + QUERIES_PER_THREAD);
System.out.println("qps: " + qps);
}
private static class QueryWorker extends Thread implements Runnable
{
private static SolrClient client = null;
private static final AtomicBoolean printingThreadChosen = new AtomicBoolean(false);
public static synchronized void init()
{
RequestConfig rc = RequestConfig.custom().setConnectTimeout(2000)
.setSocketTimeout(60000).build();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(rc)
.setMaxConnPerRoute(1024).setMaxConnTotal(4096).disableAutomaticRetries()
.build();
client = new HttpSolrClient.Builder().withBaseSolrUrl(SOLR_URL)
.withHttpClient(httpClient).build();
}
@Override
public void run()
{
boolean shouldPrint = false;
synchronized(printingThreadChosen)
{
if (!printingThreadChosen.get())
{
printingThreadChosen.set(true);
shouldPrint = true;
}
}
int printInterval = 100;
for (int i = 0; i < QUERIES_PER_THREAD; i++)
{
if (shouldPrint && (i % printInterval) == 0)
{
System.out.println("At least one thread has done " + i + " queries.");
}
SolrQuery q = null;
QueryResponse r = null;
synchronized (QueryWorker.class)
{
q = new SolrQuery();
}
q.setQuery("banjo");
long start = System.nanoTime();
try
{
r = client.query(SOLR_CORE, q);
}
catch (Exception e)
{
System.out.println("problem with query! see server log!");
}
long elapsed = (System.nanoTime() - start) / 1000000;
elapsedTimes.add((int) elapsed);
if (r != null)
{
queryTimes.add(r.getQTime());
}
}
}
}
}
22 0 0 27961124 588088 23889072 0 0 0 21 25092 51394 80 13 8 0 0
15 0 0 27952448 588088 23897924 0 0 97 20 24979 53114 79 13 8 0 0
20 0 0 27946188 588088 23906940 0 0 68 21 25029 54250 78 13 9 0 0
12 0 0 27934580 588088 23916640 0 0 265 18 25081 53158 79 13 8 0 0
15 0 0 27926680 588088 23925540 0 0 110 9997 25628 54551 79 13 8 0 0
20 0 0 27916996 588088 23933992 0 0 0 16 25078 54001 78 13 9 0 0
11 0 0 27911424 588088 23942716 0 0 18 12 24925 53875 78 13 9 0 0
12 0 0 27905492 588088 23951168 0 0 0 8 25161 54193 78 13 9 0 0
12 0 0 27894056 588088 23959676 0 0 45 31 25610 55586 78 13 9 0 0
20 0 0 27884364 588088 23968228 0 0 0 34 24799 52092 79 13 8 0 0
15 0 0 27879352 588088 23976584 0 0 26 10136 25059 49227 80 13 7 0 0
25 0 0 27867452 588088 23985000 0 0 0 1448 25958 54719 78 13 9 0 0
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
22 0 0 27863948 588088 23993512 0 0 0 18 25330 54238 78 13 9 0 0
18 0 0 27854468 588088 24002288 0 0 92 8 24985 54160 78 13 9 0 0
22 0 0 27843536 588088 24011180 0 0 0 19 25400 53489 80 13 8 0 0
17 0 0 27834084 588088 24019748 0 0 0 28 25344 54061 79 13 8 0 0
8 0 0 20495132 1180284 31888980 0 0 0 24 13720 18776 45 4 51 0 0
4 0 0 20486360 1180284 31898668 0 0 0 136 13422 18652 44 4 51 0 0
3 0 0 20476400 1180284 31908384 0 0 0 20 13771 18512 47 4 49 0 0
5 0 0 20466636 1180284 31918240 0 0 0 138 13841 18058 47 4 48 0 0
6 0 0 20456368 1180284 31927944 0 0 20 11662 13341 17923 44 4 51 0 0
4 0 0 20446036 1180284 31937924 0 0 0 137 13805 19548 45 4 51 0 0
0 0 0 20436240 1180284 31947352 0 0 0 20 13742 19044 45 4 50 0 0
2 0 0 20427220 1180284 31957804 0 0 0 134 13878 18500 46 4 49 0 0
4 0 0 20417260 1180284 31967352 0 0 0 35 13405 17849 45 4 51 0 0
8 0 0 20407588 1180284 31976736 0 0 0 142 12957 17029 42 4 54 0 0
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 20397296 1180284 31986764 0 0 0 11668 14219 19323 45 5 50 0 0
6 0 0 20387244 1180284 31996524 0 0 0 148 13535 17833 45 4 51 0 0
4 0 0 20377820 1180284 32006480 0 0 0 6 13854 18788 46 4 50 0 0
4 0 0 20368800 1180284 32016300 0 0 0 147 13844 18702 47 4 48 0 0
0 0 0 20357732 1180284 32026416 0 0 0 17 13901 19052 46 4 50 0 0
8 0 0 20348416 1180284 32036228 0 0 0 143 13796 18729 46 4 50 0 0
command: vmstat 5
0 0 0 28203972 588088 23744912 0 0 0 9 24302 54797 73 12 16 0 0
10 0 0 28195956 588088 23752684 0 0 0 15 24498 51583 76 12 12 0 0
20 0 0 28187524 588088 23760912 0 0 0 612 24750 55454 74 12 15 0 0
10 0 0 28179364 588088 23769520 0 0 0 24 25793 58401 73 13 14 0 0
24 0 0 28167828 588088 23778024 0 0 0 6126 25808 58538 74 13 13 0 0
21 0 0 28161032 588088 23786592 0 0 0 6 25063 57507 73 12 15 0 0
5 0 0 28153052 588088 23795168 0 0 0 30 25176 57501 72 13 15 0 0
15 0 0 28144764 588088 23803828 0 0 0 14 25188 57089 72 13 15 0 0
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
6 0 0 28134488 588088 23812440 0 0 0 1538 25471 57912 73 12 14 0 0
33 0 0 28126180 588088 23820952 0 0 0 14 25561 58849 73 13 14 0 0
info from vmstat man page:
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.
command: vmstat 5
3 0 0 20640632 1180284 31744300 0 0 0 142 12573 17255 42 4 54 0 0
0 0 0 20630868 1180284 31753396 0 0 0 3357 13080 17543 42 4 54 0 0
5 0 0 20620908 1180284 31763416 0 0 0 869 13793 19197 46 4 50 0 0
3 0 0 20611376 1180284 31773420 0 0 0 23 13716 19191 46 4 50 0 0
7 0 0 20601728 1180284 31783332 0 0 0 123 13609 18688 45 5 50 0 0
10 0 0 20591164 1180284 31793240 0 0 0 27 13598 18503 45 4 51 0 0
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
5 0 0 20581600 1180284 31803132 0 0 0 134 13788 19125 44 4 51 0 0
8 0 0 20569968 1180284 31813072 0 0 0 10401 13812 18984 45 5 50 0 0
4 0 0 20560884 1180284 31823104 0 0 0 3373 13642 18714 45 4 51 0 0
info from vmstat man page:
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment