6+ Million Events-Per-Second

//6+ Million Events-Per-Second

6+ Million Events-Per-Second

There is a big change and a smaller targeted change in release 7 for increasing performance. In my test release 7 hits 6.29 million of events per second on a decent CPU.

The big change is that release 7 employs byte code generation. This technique leads to higher performance as it eliminates branches and virtual calls and allows the JVM's JIT to perform further optimizations.

The small change that I'm talking about is targeted at the specific case of fully-aggregated and grouped queries. These now have a shortcut evaluation path that kicks in when computing for a single event rather than any number of events in the current processing unit.

The changes together bring a measurable improvement FOR THIS PARTICULAR TEST. This blog post is testing a simple EPL query that detects when a total hits a given number for a given group.

The measurement is shown in the below table. Read on for the explanation and code.

The EPL query is this one.

  select p0, sum(p1) from SampleEvent group by p0 having sum(p1) >= 100000000

This query totals up a field and compares it against 100 million. The code processes 100 million events. While release 6.1.0 turns out more than 4 million events per second the speed of release 7 comes in at more than 6 million events per second on the test machine.

The test setup is JVM 1.8.0_121, heap 256M (-Xms256m -Xmx256m), Intel i7 7700HQ@2.80 GHz, 16 GB system memory.

The complete test code is not that much. It's safe to measure total time since sendEvent is not an asynchronous operation. CPU utilization is 1 CPU to 100%. This test is not written to use multiple threads.

EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
epService.getEPAdministrator().createEPL("create objectarray schema SampleEvent (p0 string, p1 long)");
EPStatement stmt = epService.getEPAdministrator().createEPL("select p0, sum(p1) from SampleEvent group by p0 having sum(p1) >= 100000000");
SupportUpdateListener listener = new SupportUpdateListener();
EventSender sender = epService.getEPRuntime().getEventSender("SampleEvent");

// warm-up
for (int i = 0; i < 100000; i++) {
    sender.sendEvent(new Object[]{"G1", 1L});

// measure
long start = System.currentTimeMillis();
for (int i = 0; i < 100000000; i++) {
    sender.sendEvent(new Object[]{"G2", 1L});
long delta = System.currentTimeMillis() - start;

System.out.println("Delta: " + delta);
System.out.println("Listener received group: " + listener.assertOneGetNewAndReset().get("p0"));
2017-10-30T16:40:24+00:00 Performance|