high performance stream processing

Download High performance stream processing

If you can't read please download the document

Upload: glenn-renfro

Post on 15-Apr-2017

172 views

Category:

Software


0 download

TRANSCRIPT

High Performance Stream ProcessingBy Stephane Maldini, Glenn Renfro, David Turanski@smaldini, @cppwfs, @dturanski

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

SPRINGONE2GXWASHINGTON, DC

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Performance as it pertains to:

Message flow

Serialization

Processing

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Message Flow: The Myth?

1 million events a second?

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Message Flow: The Myth?

It Dependshttps://spring.io/blog/2015/06/17/spring-xd-benchmarks-part-1

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Message Flow: The Myth?

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

HardwareCheck Network speed iperfCheck Disk Read Write speeddd Processor Speed (specs)

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Hardware: Network

1 Gb EthernetMsg SizeMsgs/Sec1001,250,0001,000125,00010,00012,500100,0001,250

10 Gb EthernetMsg SizeMsgs/Sec10012,500,0001,0001,250,00010,000125,000100,00012,500

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Hardware: Disk dd bs=1M count=256 if=/dev/zero of=testwill just commit your 128 MB of data into a RAM bufferinitially fast but server is still writing to disk after test

dd bs=1M count=256 if=/dev/zero of=/tmp/testfile conv=fdatasyncThis tells dd to require a complete sync once, right before it exits.Ensures all data is on the disk before calculating result

https://romanrm.net/dd-benchmark

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Message Size

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Message Size

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

TransportsRabbitperftest https://www.rabbitmq.com/java-tools.htmlKafkaProducerPerformancekafka-consumer-perf-test.shhttps://engineering.linkedin.com/kafka/benchmarking-apache-kafka-2-million-writes-second-three-cheap-machines

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Testing ToolsSpring XD load-generator-sourcethroughputhttps://github.com/spring-projects/spring-xd-modules

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

ConfigurationKafkaBatchSize Default is 16384 .0.8.2.1 vs .0.8.1.1RabbitprefetchDefault for XD is 1

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Batchinghttps://github.com/cppwfs/rabbitmqsinkhttps://github.com/cppwfs/rabbitmqsource

Spring AMQPBatch SizeMsgs Per Sec118,46510158,564100453,926

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Network HopsAdds a cost per hop Options:Direct BindingComposed ModulesCustom Module

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

One last little thingJMX is disabled by defaultWhen enabled it took a performance hit because how SI was capturing stats via its exporters

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Object SerializationPOJO byte[] required for transporting data between remote processesXD uses Kryo except when the payload type is byte[] or StringXD supports optimizing Kryo for known payload types

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Serialization Benchmarks

An excellent comparative JVM serializers benchmark:https://github.com/eishay/jvm-serializers/wikiBest case: ~1500 ns

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Serialization Benchmarks

{"media": {"uri": "http://javaone.com/keynote.ogg", "title":"Javaone Keynote", "width":640, "height":480,"format":"video/mpg4","duration":18000000,"size":58982400,"bitrate":262144,"persons":["Bill Gates", "Steven Jobs"],"player":"JAVA","copyright":"" },"images":[{"uri": "http://javaone.com/keynote_large.jpg","title":"Javaone Keynote","width": 1024,"height":768,"size":"LARGE"},{ "uri": "http://javaone.com/keynote_small.jpg", "title":"Javaone Keynote","width": 320,"height":240, "size":"SMALL"}]}

Domain Object (as JSON):

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Object SerializationSize matters: YMMVManually optimized Kryo ser/deser ~ 1500 ns = 1.5 s = .0015 ms. Kafka XD;1000B messages ~ 500,000 msg/sec2000 ns per messageSerialization overhead~ 285174 msg/sec (source|sink)At 50,000 msg/sec, the overhead may still be significant (source|p1|p2|p3|sink)

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Optimizing Kryo in XDDisable references - If you know payload types do not contain cyclic references. xd.codec.kryo.references=false (in servers.yml)This is a global setting for all streamsRegister a custom serializer for a known payload typeInstall a jar with containing the required beans in xd/lib. XD will auto-configure these

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Custom Serializers in XD

public PojoCodec(java.util.List kryoRegistrars, boolean useReferences)

package spring.xd.bus.ext;...

@Configurationpublic class CustomKryoRegistrarConfig {@Beanpublic KryoRegistrar myCustomRegistration() { List registrations = new ArrayList(); registrations.add(new Registration(MyObject.class, new MySerializer(),62));return new KryoRegistrationRegistrar(registrations);}}

XD scans this package for beans of type KryoRegistrar

Each Registration associates a type to a serializer and a unique ID

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Custom Serializers in XD

public class AddressSerializer extends Serializer {@Overridepublic void write(Kryo kryo, Output output, Address address) {output.writeString(address.getStreet());output.writeString(address.getCity());output.writeString(address.getCountry());}

@Overridepublic Address read(Kryo kryo, Input input, Class type) {return new Address(input.readString(),input.readString(),input.readString()); }}

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Serializable Domain Object

public class Address implements KryoSerializable {...

@Overridepublic void write(Kryo kryo, Output output) {output.writeString(this.street);output.writeString(this.city);output.writeString(this.country);}

@Overridepublic void read(Kryo kryo, Input input) {this.street = input.readString();this.city = input.readString();this.country = input.readString();}}(+) Simple: This works out of the box with no additional configuration(-) Requires access to source or wrapping(-) Internal benchmarks indicate this is not as fast as registering a custom serializer(+) Easy way to delegate to a different serialization library

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Benchmarking Your Custom Serializers

Sample ResultsSer (ns)Desr (ns)Baseline2710.54590.9Serializable Domain Object1663.32579.1Custom Serializers1126.12873.8

The spring-xd-samples repo includes a serialization-benchmarks projecthttps://github.com/spring-projects/spring-xd-samples/tree/master/serialization-benchmarksLets look at some code

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

What about Processing ?Source Msg/s > Sink Msg/s ?Rate limited by SinkBlocking transformation (http, file) ?Rate limited by blocking ProcessorPolling Sources Pausing ?Rate limited by small Prefetch properties

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Mitigating Cost of IONegative impact ? Scale Out ?Loosing Data Affinity (colocation)Network costScale Up ? Message passing OverheadMore In-Flight Data

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Mitigating Cost of IONegative impact ? Scale Out ?Loosing Data Affinity (colocation)Network costScale Up ? Message passing OverheadMore In-Flight Data

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Blocking IO

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Asynchronous IO

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Asynchronous IOMitigate temporarily slow processors/sink

Back to degraded mode when queue full

Async Hand-Off generates Garbage

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Reactor Core: Efficient AsynchronousTrade-off Memory vs Garbage generationPre-Allocated Ring Buffer

Concurrent consuming without duplicating buffer contentRing Buffer Consumer Sequences

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

RingWhat?

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Module Teasing

@EnableReactorModule(concurrency = 4) /* Invoke accept() 4 times */public class Sample implements ReactiveProcessor {

@Override public void accept(Publisher messageStream, /* A Ring Buffer Consumer */ReactiveOutput output) { /* A Channel Output bridge */ output.writeOutput(messageStream); }}

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Questions

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Microservices to Fast DataJohn T. DaviesLearn More. Stay Connected.

@springcentralSpring.io/video

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

USING THIS TEMPLATE

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

STOP! Download Fonts Now.PLEASE DOWNLOAD AND INSTALL THESE FONTS BEFORE CREATING YOUR PRESENTATION. You can download the fonts herehttps://www.dropbox.com/s/na8jewnsp8dp659/SpringOne-2015-Fonts.zip?dl=0

Fonts included in the ZIP file:Proxima Nova (body text)Domine (included but no longer needed)

http://www.fontspring.com/support/installing/how-do-i-install-fonts-on-my-machttp://www.fontspring.com/support/installing/how-do-i-install-fonts-on-my-windows-pc

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

IntroThis template has been carefully prepared with specific layouts, colors, fonts and more. This short intro will outline the basic components of this template.

Note: This template includes slides with approved color palette, fonts, logos and clip art. Its a good idea to keep these slides in order to quickly access these assets then delete the slides when you have finished creating your presentation.

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Inserting New Slides and Applying LayoutsTo create different types of slides, select New Slide and apply desired LayoutIf you make formatting changes to a slide and want to reapply the default settings, click Reset

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

LayoutsThere are 13 layoutsTitle Only Standard slide with no text content box, do not use for section titleTitle and Content (1 Col) Standard slide with title and text content boxTitle and Content (2 Col) Standard slide with title and two text content boxesComparison Standard slide with title and two text content boxes with subtitlesSection Title Use between sectionsNo textTable Quick and easy way to get a table with brand colorsBar Chart Quick and easy way to get a bar chart with brand colorsLine Chart Quick and easy way to get a line chart with brand colorsPie Chart Quick and easy way to get a pie chart with brand colorsCode Formatting Quick and easy way to get preferred code formattingTitle Slide Presentation title with author name and contact info. Use only once in presentation.Completely blank A totally blank, white slide. Use sparingly.

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Title Proxima Nova Bold (30pt)All body text is Proxima Nova RegularSubhead (18pt)Level Two (18pt)Level Three (18pt)Level Four (18pt)Line spacing is set in master slides

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Brand Colors

R: 241G: 241B: 241

R: 153G: 153B: 153

R: 109G: 179B: 63SpringBrand Colors

R: 52G: 48B: 45SpringOne 2GX 2015Theme Colors

R: 83G: 83 B: 83

R: 12G: 48B: 100

R: 156G: 209B: 121

R: 204G: 204 B: 204

R: 38G: 97B: 168

R: 114G: 163B: 211

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Code Slide

// This is Arial: 18 pt or higher pleasepublic class TransferServiceImpl implements TransferService { public TransferServiceImpl(AccountRepository ar) { this.accountRepository = ar; } }

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Learn More. Stay Connected.

@springcentralSpring.io/video

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Safe Harbor StatementThe following is intended to outline the general direction of Pivotal's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of Pivotal offerings, future updates or other planned modifications is subject to ongoing evaluation by Pivotal and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding Pivotal's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for Pivotal's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation.

If you are a pivotal employee and your talk contains forward facing information, please include this slide at the beginning or conclusion of the presentation.

Remove this text box before presenting.

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

LOGOS & ICONS

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Logos

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Event Logos and Icons

Logo on dark

Logo on light

Date logo on dark

Date logo on light

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Spring Project Icons

SpringFrameworkSpringSecuritySpringDataSpringBatchSpringIntegrationSpringReactorSpringAMQPSpringHateoasSpringMobileSpringAndroidSpringSocialGroovySpringWeb ServicesSpringWeb FlowSpringXDSpringBootSpringLDAPGrailsPNG and PSD files for all Spring projects can be found herehttps://www.dropbox.com/sh/5rbbt8v6evvm7xm/AAAZmhgf0zglGHZUWYhPvojFa?dl=0

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Spring Tool Suite Icons

Spring Tool SuiteGroovy / Grails Tool Suite

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Spring Document Icons

Spring FrameworkToolsSupportGuidesReference AppTutorials

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Additional Spring Icons

ContinuousIntegration

Metrics

Forums /Discussion

Blog

@

IssuesAllAuthorBroadcastDateNewsEventReleasesAppleLinuxEngineeringWindowsProfessionalSupportCommunitySupportLocation

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Icon GuidelinesThese icons can be used when Spring icons are not appropriate.Max icon size is 2.08 inches anything larger and the icon will be blurryIcons are transparent and can be placed over images and other objectsTo use an icon, simply choose, copy and paste200x200 PNG files can be found herehttps://www.dropbox.com/sh/wy65b4l5t4fv9b4/AAD1LMHcOtwJSTbNu23zqywka?dl=0

Max icon size:2.08 inches

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

CHARTS & TABLES

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Sample Pie Chart

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Sample Bar Chart

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Sample Line Chart

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/

Sample Table

2007200820092010Category 12.46.44.16.6Category 28.24.53.23.8Category 34.63.21.99.6Category 46.73.33.42.2Category 54.35.67.13.4

Unless otherwise indicated, these slides are 2013-2015 Pivotal Software, Inc. and licensed under aCreative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/