+ All Categories
Home > Software > Asynchronous Design with Spring and RTI: 1M Events Per Second

Asynchronous Design with Spring and RTI: 1M Events Per Second

Date post: 02-Jul-2015
Category:
Upload: spring-io
View: 697 times
Download: 0 times
Share this document with a friend
Description:
An application designer usually has to choose where to trade flexibility for specificity (and thus usually performance); knowing when and where to do so is an art and requires experience. This talk will share over a decades worth of experience making these decisions and the learnings from developing Pivotal's successful Real Time Intelligence (RTI) product using the latest versions of Spring projects: Integration, Data, Boot, MVC/REST and XD. A walk through the RTI architecture will provide the base for an explanation about how Spring performs at hundreds (and millions) of events/operations per second and the techniques that you can use right now in your own Spring applications to minimise resource utilisation and gain performance.
45
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. Asynchronous Design: 1M events per second with Spring By Stuart Williams
Transcript
Page 1: Asynchronous Design with Spring and RTI: 1M Events Per Second

© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.

Asynchronous Design: 1M events per

second – with Spring

By Stuart Williams

Page 2: Asynchronous Design with Spring and RTI: 1M Events Per Second

Bio

2

Stuart Williams

• Software Engineer at Pivotal – RTI project lead

@pidster

Page 3: Asynchronous Design with Spring and RTI: 1M Events Per Second

What is this all about?

• We built a product using Pivotal products

• Learned some lessons

• We found a few limitations & some room for

improvement…

• … but we addressed them & now things go faster.

A lot faster.

3

Page 4: Asynchronous Design with Spring and RTI: 1M Events Per Second

Dogfood

• Built with Spring IO Platform • Boot, Data, Integration, Reactor, AMQP, SpEL, Shell (and a little Groovy)

• GemFire

• RabbitMQ

4

Spring

Framework Spring

Data

Spring

Integration

Spring

Reactor

Spring

AMQP

Spring

Hateoas Groovy

Spring

Boot

Page 5: Asynchronous Design with Spring and RTI: 1M Events Per Second

Questions for you

• Heard of Spring Integration?

• Tried it?

• In production?

• Heard of Reactor?

• Tried it?

• In production?

5

Page 6: Asynchronous Design with Spring and RTI: 1M Events Per Second

RTI

6

Page 7: Asynchronous Design with Spring and RTI: 1M Events Per Second

What is RTI?

• RTI == ‘Real Time Intelligence’ • Stream processing application

• Location based services

• Analytics (e.g. network health)

• Telecom network data • ‘Control plane’ is meta data

• ‘User plane’ is actual data (30x more)

• Rich data model

7

Page 8: Asynchronous Design with Spring and RTI: 1M Events Per Second

Input Data Rates

RTI*

• 100k/s average

• 120k/s daily peak

• 1M/s annual peak

8

*Control-plane only, user-plane is 20x

Page 9: Asynchronous Design with Spring and RTI: 1M Events Per Second
Page 10: Asynchronous Design with Spring and RTI: 1M Events Per Second

Input Data Rates

RTI*

• 100k/s baseline

• >120k/s daily peak

• >1M/s annual peak

10

*Control-plane only, user-plane is 20x

Twitter**

• 6k/s average

• 9k/s daily peak

• 30k/s large events

**Source @catehstn twitter.com/catehstn/status/494918021358813184

Page 11: Asynchronous Design with Spring and RTI: 1M Events Per Second

Load Characteristics

• Low numbers of inbound connections

• High rates, micro-bursts

• Occasional peaks of nearly 2x, rare peaks of 10x

• Variable payload size (200B – 300KB)

• Internal fan-outs multiple event rates

11

Page 12: Asynchronous Design with Spring and RTI: 1M Events Per Second

More statistics…

• 100k/s order of magnitude • 8,640,000,000 (per day)

• An Integer based counter will ‘roll over’ in ~2 days

• 400Mbps of raw data (‘control plane’) • 10Gbps NICs required to support traffic peaks

• Logging! Any verbose errors can blow a disk away

• Queues backing up == #fail

12

Page 13: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architecture

13

Page 14: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architecture

14

Ingester Ingest Grid Distribution

Analytics

AMQP

Metrics

Firehose

HTTP HTTP

WAN

Queue

Page 15: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architectural Challenges

• Ingest • Responsibility

• Micro-bursts

• Infrastructure considerations • Compute

• Memory

• Disk

• Network

15

Page 16: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architecture

16

Ingester Ingest Grid Distribution

Analytics

AMQP

Metrics

Firehose

HTTP HTTP

WAN

Queue

Page 17: Asynchronous Design with Spring and RTI: 1M Events Per Second

Ingester Architecture

17

Ingester

• Spring Integration • TCP Server

• Transformer

• Filters

• Reactor Stream

• GemFire client

• Single process • Multiple protocols – different rates & sizes

Page 18: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architecture

18

Ingester Ingest Grid Distribution

Analytics

AMQP

Metrics

Firehose

HTTP HTTP

WAN

Queue

Page 19: Asynchronous Design with Spring and RTI: 1M Events Per Second

Analytics Architecture

19

Analytics • Reactor

• SpEL evaluation

• Hundreds of expression

calculations per event

• Collate across nodes

• Output to File or AMQP

Page 20: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architecture

20

Ingester Ingest Grid Distribution

Analytics

AMQP

Metrics

Firehose

HTTP HTTP

WAN

Queue

Page 21: Asynchronous Design with Spring and RTI: 1M Events Per Second

Architecture

21

Distribution

• Spring Integration • Enrichers

• Filters

• Reactor Stream

• Output to File / AMQP / JDBC

• Membership checks

• LBS, opt-in’s

Page 22: Asynchronous Design with Spring and RTI: 1M Events Per Second

First Ingester solution

22

Page 23: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution #1 – ‘Naïve’ proof of concept

• Build codecs • More on this in John Davies’ “Big Data In Memory” talk later today…

• Spring Integration (SI) pipeline • TCP Inbound Adapter

• Transformer

• Filters

• Outbound adapter

23

Page 24: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution #1 – ‘Naïve’ proof of concept

24

Page 25: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution #1 results

• Message UUID generation was slow!

• SpEL-based method resolution was slow!

• Standard Channels added overhead!

• Single event output was slow!

25

Page 26: Asynchronous Design with Spring and RTI: 1M Events Per Second

Ingester Mark 2

26

Page 27: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution #2 – Use interfaces

27

Page 28: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution #2 – Use interfaces

• Use the IdGenerator interface

• Use specific endpoint interfaces • … we’ll come back to SpEL …

• Use a Chain

• Use an Aggregator to build a batch

28

Page 29: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution #2 results

• IdGenerator helped a lot

• Specific interfaces not recognised!

• Using <int:chain helped

• Aggregator helped, but is too slow

• <int:tcp-inbound-adapter is too slow

29

Page 30: Asynchronous Design with Spring and RTI: 1M Events Per Second

Many whiteboards later…

30

Page 31: Asynchronous Design with Spring and RTI: 1M Events Per Second

Many whiteboards later…

31

Page 32: Asynchronous Design with Spring and RTI: 1M Events Per Second

Working version

32

Page 33: Asynchronous Design with Spring and RTI: 1M Events Per Second

Solution N

33

Message-only Filters

Reference Data Filters

Batcher

GB

IUPS

IUCS

A

Radius/Diamete

r

4G

Page 34: Asynchronous Design with Spring and RTI: 1M Events Per Second

Working version

• Netty / Reactor TCP

• IdGenerator

• Specific endpoint interfaces

• Chain

• Reactor Stream based batching

• + many improvements & enhancements

34

Page 35: Asynchronous Design with Spring and RTI: 1M Events Per Second

Roundup

35

Page 36: Asynchronous Design with Spring and RTI: 1M Events Per Second

Spring Improvements

• Performance • Spring Integration

• SpEL

• Reactor

• Spring XD benefits from these upgrades

36

Page 37: Asynchronous Design with Spring and RTI: 1M Events Per Second

Spring Integration

37

Page 38: Asynchronous Design with Spring and RTI: 1M Events Per Second

Spring Integration

• UUID generator

• MessageBuilderFactory & MutableMessage

• Dispatcher optimisation

• SpEL parser caching

• Counters are ‘long’

• Interfaces used directly – if you’re specific SI

respects that

38

Page 39: Asynchronous Design with Spring and RTI: 1M Events Per Second

Spring Expression Language

• Compilation of expressions • Configuration options

• SI just re-evaluates expressions

• Trade-offs & limitations

• Much, much faster

39

Page 40: Asynchronous Design with Spring and RTI: 1M Events Per Second

SpEL demo

40

Page 41: Asynchronous Design with Spring and RTI: 1M Events Per Second

Reactor

• Drop-in replacements • Thread pools, dispatchers

• TCP/UDP Server & Client • Much faster – lower resource utilisation

• Stream API • Batching and other functionality

• More about Reactor • Thu, 8.30am “Building Reactive Applications…”

41

Page 42: Asynchronous Design with Spring and RTI: 1M Events Per Second

Batching endpoint code

42

Page 43: Asynchronous Design with Spring and RTI: 1M Events Per Second

Summary

• Spring Integration is much faster

• Good performance means better resource

utilisation

• For cloud applications cost savings can be dramatic

• Batching payloads makes a big difference

• Many applications wait on network IO

• Trade-off risk of data loss for performance

• Reactor FTW

43

Page 44: Asynchronous Design with Spring and RTI: 1M Events Per Second

Questions

44

Page 45: Asynchronous Design with Spring and RTI: 1M Events Per Second

45

Learn More. Stay Connected

Tweet #rti #s2gx if you’d like to go faster

@pidster

“Big Data in Memory”

John Davis – Trinity 1-2 4.30pm

@springcentral | spring.io/video


Recommended