SlideShare uma empresa Scribd logo
1 de 31
Event Driven with LibUV and
ZeroMQ
Phase I Summary
Luke.jf.luo@gmail.com
Outline
● Algo Trading Business Flow Review
● Order Module Design: Current Flaw
● Distributed System: Theory Review
● Event Driven System: Review
● Event Driven Design In Algo Trading
● Project Plan
Algo Trading Flow
I1 I2 I3 …... In
任务
( 下达 /
取消 /
停止 )
Instrument (Buy/Sell)
下单
撤单
下单
撤单
步长步长
.
.
.
...
...
….........
...
...
….........
...
...
….........
End
…............
Current Design Flaw
● Bad Assumptions
– Serial Execution Among Instructments
– Batch Job ( 1 Sec Interval)
– I/O Cost/ Latency: Neglectable
– Computation Cost/Latency: Neglectable
– No Uncertainty
Reality
● Parallel execution of Instruments
● Market change in Ms, 1 Sec (or More) fixed reponse interval
is 1000X
● I/O is SLOW comaring to CPU speed (10^9 order)
● Communication Channel will Break
● Only God have ALL TIMELY information for decision making.
We people live in UNCERTAINTY
● Tradeoff: Best Effort Decision versus Perfect Decision
Distributed System: Our Reality
● Parallel: Everything is Moving
● Error Prone (Fault): No 99.9999999....%
Gurantee
● Uncertainty: Who/What/Where/When/Why
● Concensus/Consistency with HIGH COST
● Speed limit: Light Travels at (300,000km/Sec)
CAP: No Perfect World
Case:Two Generals' Problem
Case:Two Generals' Problem
● 1975 . E. A. Akkoyunlu, K. Ekanadham, and R.
V. Huber "Some Constraints and Trade-offs in
the Design of Network Communications"
● “A pragmatic approach to dealing with the Two
Generals' Problem is to use schemes that
accept the uncertainty of the communications
channel and not attempt to eliminate it, but
rather mitigate it to an acceptable degree.”
TCP: Connection Establishment
TCP: Sliding Window
Event Driven: History
● 1960s: Mainframe. Batch Job Oriented
● 1970s: Unix. Interactive,Timesharing Terminal
● GUI programming:
– Xerox : mouse
– Apple: Apple II
– Microsoft: Windows
– MIT: X windows
– …...
Event Driven: Now
● Libuv: Chrome browser, node.js...
● Libev/libevent
● Boost ASIO
● ACE/ICE
● Qt event loop
● Glib/Gevent
Event Driven: Now
● Nginx,apache,Twisted,Comet
● Node.js
● Python Asyncio
● Go channel
● Scala Actor
● C++ 11 Promise/Future,Coroutine,Closure
● …........
I/O Modelling
●  blocking I/O
●  nonblocking I/O
●  I/O multiplexing (select and poll)
●  signal driven I/O (SIGIO)
●  asynchronous I/O (the POSIX aio_functions)
Quoted from “UNIX Network Programming Volume
1”
Async/Event Driven Design:
Reactor
Proactor
So we are event-driven ready.
But...
● Components are mostly event driven
● Interface Among components are BLOCKING
INTERFACE! (block/wait/timeout....)
● One blocking will ruin the whole infrastructure!
● “Public Land Tragic”
class StringQue : public MsgQueBase
StringQueue is everywhere
[luke@rmbp service_multichannel]$ find . -name StringQue.h
./orderservice/OMSInfterfaceDemo/StringQue.h
./optionhedgeservice/optionhedgeservice/StringQue.h
./queryservice/queryservice/StringQue.h
./queryservice/queryservice_auto_qt_profitchart/StringQue.h
./queryservice/queryservice_auto_qt/StringQue.h
./strategyservice_new/hedgefutureservice/StringQue.h
./strategyservice_new/algoorderservice/StringQue.h
./strategyservice_new/algoorderserviceFuture/StringQue.h
./strategyservice/hedgefutureservice/StringQue.h
./strategyservice/optionhedgeservice/optionhedgeservice/StringQue.h
./strategyservice/algoorderservice/StringQue.h
./strategyservice/algoorderserviceFuture/StringQue.h
./quoteservice/quoteservicelevel2/StringQue.h
./quoteservice/quoteservicelevel2datafeed/StringQue.h
./quoteservice/quoteservicelevel2_new/StringQue.h
./quoteservice/quoteservicelevel2datafeed_clb/StringQue.h
How we use StringQueue?
Vision
● A fault tolerant, responsive trading platorm
– Respond to every marktet tick/heartbeat
● Maintain “fresh” market snapshot
● React as every tick comes
– Async, Parallel order fullfillment
● Handle > 1000 orders one server instance without
pressure
● Milisec level processing delay per order action
Vision: Unified Event Loop
Libuv
event Loop
ZeroMq
socket
Normal socket
timer
Other Async events
eventfd
fd
timer_t handle
async_t handle
Parallel Tasks req_t
Thread Pool
Async Tasks
Order Fullfill
Market Snapshot
update
Other
Event Loop
Other business
modules
Async Programming
● Callback
● Task(threading)
● Future/Promise
● Async I/O
● Coroutine
●
Trading Version 2
I1 I2 I3 …... In
下单
撤单
下单
撤单
timeouttimeout
.
.
.
...
...
...
...
….........
...
...
….........
End
…............
tick
….........
EndEndEnd
tick
tick
tick
Project Plan
● Goal: A testable new framwork
– Algotrading as typical business test case
– High throughput, low latency
– Fault Tolerant with sensible tradeoff strategy
Side by Side comparison with current order system
Task:
● Project Managment (Wei Song)
● Event Loop, ZeroMQ (Tie Gang/Luke)
● Market snapshot update (Wei Song/Ze Yu)
● Order business module rewrite(Ze Yu/Wei Song)
● Testing environment (Wei Song/Tie Gang)
– Simulation data/replay
– OMS simulator
● Testing
– All
– + Calvin + other business staff
Schedule?
● What can we accomplish before Spring
Festival?

Mais conteúdo relacionado

Mais procurados

Performance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State StoresPerformance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State Storesconfluent
 
Kafka At Scale in the Cloud
Kafka At Scale in the CloudKafka At Scale in the Cloud
Kafka At Scale in the Cloudconfluent
 
Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...
Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...
Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...Flink Forward
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaJiangjie Qin
 
How to Lock Down Apache Kafka and Keep Your Streams Safe
How to Lock Down Apache Kafka and Keep Your Streams SafeHow to Lock Down Apache Kafka and Keep Your Streams Safe
How to Lock Down Apache Kafka and Keep Your Streams Safeconfluent
 
Hello, kafka! (an introduction to apache kafka)
Hello, kafka! (an introduction to apache kafka)Hello, kafka! (an introduction to apache kafka)
Hello, kafka! (an introduction to apache kafka)Timothy Spann
 
Streaming data for real time analysis
Streaming data for real time analysisStreaming data for real time analysis
Streaming data for real time analysisAmazon Web Services
 
Singer, Pinterest's Logging Infrastructure
Singer, Pinterest's Logging InfrastructureSinger, Pinterest's Logging Infrastructure
Singer, Pinterest's Logging InfrastructureDiscover Pinterest
 
Oracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data Streaming
Oracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data StreamingOracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data Streaming
Oracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data StreamingMichael Rainey
 
On-boarding with JanusGraph Performance
On-boarding with JanusGraph PerformanceOn-boarding with JanusGraph Performance
On-boarding with JanusGraph PerformanceChin Huang
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controllerconfluent
 
Element Management Subsystem
Element Management SubsystemElement Management Subsystem
Element Management Subsystemdevalnaik
 
Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...
Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...
Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...HostedbyConfluent
 
Zookeeper Architecture
Zookeeper ArchitectureZookeeper Architecture
Zookeeper ArchitecturePrasad Wali
 
Apache Superset - open source data exploration and visualization (Conclusion ...
Apache Superset - open source data exploration and visualization (Conclusion ...Apache Superset - open source data exploration and visualization (Conclusion ...
Apache Superset - open source data exploration and visualization (Conclusion ...Lucas Jellema
 
Transparent Data Encryption in PostgreSQL and Integration with Key Management...
Transparent Data Encryption in PostgreSQL and Integration with Key Management...Transparent Data Encryption in PostgreSQL and Integration with Key Management...
Transparent Data Encryption in PostgreSQL and Integration with Key Management...Masahiko Sawada
 
Kafka at Peak Performance
Kafka at Peak PerformanceKafka at Peak Performance
Kafka at Peak PerformanceTodd Palino
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controllerconfluent
 
Introduction to Kafka Cruise Control
Introduction to Kafka Cruise ControlIntroduction to Kafka Cruise Control
Introduction to Kafka Cruise ControlJiangjie Qin
 

Mais procurados (20)

Performance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State StoresPerformance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State Stores
 
Kafka At Scale in the Cloud
Kafka At Scale in the CloudKafka At Scale in the Cloud
Kafka At Scale in the Cloud
 
Envoy and Kafka
Envoy and KafkaEnvoy and Kafka
Envoy and Kafka
 
Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...
Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...
Flink Forward San Francisco 2019: Moving from Lambda and Kappa Architectures ...
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache Kafka
 
How to Lock Down Apache Kafka and Keep Your Streams Safe
How to Lock Down Apache Kafka and Keep Your Streams SafeHow to Lock Down Apache Kafka and Keep Your Streams Safe
How to Lock Down Apache Kafka and Keep Your Streams Safe
 
Hello, kafka! (an introduction to apache kafka)
Hello, kafka! (an introduction to apache kafka)Hello, kafka! (an introduction to apache kafka)
Hello, kafka! (an introduction to apache kafka)
 
Streaming data for real time analysis
Streaming data for real time analysisStreaming data for real time analysis
Streaming data for real time analysis
 
Singer, Pinterest's Logging Infrastructure
Singer, Pinterest's Logging InfrastructureSinger, Pinterest's Logging Infrastructure
Singer, Pinterest's Logging Infrastructure
 
Oracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data Streaming
Oracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data StreamingOracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data Streaming
Oracle GoldenGate and Apache Kafka A Deep Dive Into Real-Time Data Streaming
 
On-boarding with JanusGraph Performance
On-boarding with JanusGraph PerformanceOn-boarding with JanusGraph Performance
On-boarding with JanusGraph Performance
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controller
 
Element Management Subsystem
Element Management SubsystemElement Management Subsystem
Element Management Subsystem
 
Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...
Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...
Stream processing IoT time series data with Kafka & InfluxDB | Al Sargent, In...
 
Zookeeper Architecture
Zookeeper ArchitectureZookeeper Architecture
Zookeeper Architecture
 
Apache Superset - open source data exploration and visualization (Conclusion ...
Apache Superset - open source data exploration and visualization (Conclusion ...Apache Superset - open source data exploration and visualization (Conclusion ...
Apache Superset - open source data exploration and visualization (Conclusion ...
 
Transparent Data Encryption in PostgreSQL and Integration with Key Management...
Transparent Data Encryption in PostgreSQL and Integration with Key Management...Transparent Data Encryption in PostgreSQL and Integration with Key Management...
Transparent Data Encryption in PostgreSQL and Integration with Key Management...
 
Kafka at Peak Performance
Kafka at Peak PerformanceKafka at Peak Performance
Kafka at Peak Performance
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controller
 
Introduction to Kafka Cruise Control
Introduction to Kafka Cruise ControlIntroduction to Kafka Cruise Control
Introduction to Kafka Cruise Control
 

Destaque

Archlinux dev environment
Archlinux dev environmentArchlinux dev environment
Archlinux dev environmentLuke Luo
 
Who Is a Software Architect?
Who Is a Software Architect?Who Is a Software Architect?
Who Is a Software Architect?Yegor Bugayenko
 
'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...
'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...
'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...TEST Huddle
 
FOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQFOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQpieterh
 
ZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 LabsZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 LabsJames Dennis
 
libuv: cross platform asynchronous i/o
libuv: cross platform asynchronous i/olibuv: cross platform asynchronous i/o
libuv: cross platform asynchronous i/oSaúl Ibarra Corretgé
 
Overview of ZeroMQ
Overview of ZeroMQOverview of ZeroMQ
Overview of ZeroMQpieterh
 

Destaque (9)

Archlinux dev environment
Archlinux dev environmentArchlinux dev environment
Archlinux dev environment
 
Who Is a Software Architect?
Who Is a Software Architect?Who Is a Software Architect?
Who Is a Software Architect?
 
'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...
'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...
'Quality Engineering: Build It Right The First Time' by Allan Woodcock, Shoba...
 
Protocol Buffer.ppt
Protocol Buffer.pptProtocol Buffer.ppt
Protocol Buffer.ppt
 
FOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQFOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQ
 
ZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 LabsZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 Labs
 
A deep dive into libuv
A deep dive into libuvA deep dive into libuv
A deep dive into libuv
 
libuv: cross platform asynchronous i/o
libuv: cross platform asynchronous i/olibuv: cross platform asynchronous i/o
libuv: cross platform asynchronous i/o
 
Overview of ZeroMQ
Overview of ZeroMQOverview of ZeroMQ
Overview of ZeroMQ
 

Semelhante a Event Driven with LibUV and ZeroMQ

Asynchronous programming intro
Asynchronous programming introAsynchronous programming intro
Asynchronous programming introcc liu
 
Common mistakes in android development
Common mistakes in android developmentCommon mistakes in android development
Common mistakes in android developmentHoang Nguyen Huu
 
Reactive mistakes - ScalaDays Chicago 2017
Reactive mistakes -  ScalaDays Chicago 2017Reactive mistakes -  ScalaDays Chicago 2017
Reactive mistakes - ScalaDays Chicago 2017Petr Zapletal
 
ekbpy'2012 - Антон Патрушев - ZeroMQ
ekbpy'2012 - Антон Патрушев - ZeroMQekbpy'2012 - Антон Патрушев - ZeroMQ
ekbpy'2012 - Антон Патрушев - ZeroMQit-people
 
Async Web Frameworks in Python
Async Web Frameworks in PythonAsync Web Frameworks in Python
Async Web Frameworks in PythonRyan Johnson
 
IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015哲也 廣田
 
Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...
Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...
Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...Thoughtworks
 
Demo the reactive jargons
Demo the reactive jargonsDemo the reactive jargons
Demo the reactive jargonsThoughtworks
 
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...Anne Nicolas
 
An Abusive Relationship with AngularJS
An Abusive Relationship with AngularJSAn Abusive Relationship with AngularJS
An Abusive Relationship with AngularJSMario Heiderich
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?Maciej Lasyk
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
The art of concurrent programming
The art of concurrent programmingThe art of concurrent programming
The art of concurrent programmingIskren Chernev
 
smalltalk numbercrunching
smalltalk numbercrunchingsmalltalk numbercrunching
smalltalk numbercrunchingDaniel Poon
 
IoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
IoTivity Tutorial: Prototyping IoT Devices on GNU/LinuxIoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
IoTivity Tutorial: Prototyping IoT Devices on GNU/LinuxSamsung Open Source Group
 
Free the Functions with Fn project!
Free the Functions with Fn project!Free the Functions with Fn project!
Free the Functions with Fn project!J On The Beach
 
jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...
jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...
jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...jSession
 
Voxxed Days Villnius 2015 - Burning Marshmallows
Voxxed Days Villnius 2015 - Burning MarshmallowsVoxxed Days Villnius 2015 - Burning Marshmallows
Voxxed Days Villnius 2015 - Burning MarshmallowsRon Munitz
 

Semelhante a Event Driven with LibUV and ZeroMQ (20)

Asynchronous programming intro
Asynchronous programming introAsynchronous programming intro
Asynchronous programming intro
 
Common mistakes in android development
Common mistakes in android developmentCommon mistakes in android development
Common mistakes in android development
 
Reactive mistakes - ScalaDays Chicago 2017
Reactive mistakes -  ScalaDays Chicago 2017Reactive mistakes -  ScalaDays Chicago 2017
Reactive mistakes - ScalaDays Chicago 2017
 
ekbpy'2012 - Антон Патрушев - ZeroMQ
ekbpy'2012 - Антон Патрушев - ZeroMQekbpy'2012 - Антон Патрушев - ZeroMQ
ekbpy'2012 - Антон Патрушев - ZeroMQ
 
Async Web Frameworks in Python
Async Web Frameworks in PythonAsync Web Frameworks in Python
Async Web Frameworks in Python
 
IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015IoT with Ruby/mruby - RubyWorld Conference 2015
IoT with Ruby/mruby - RubyWorld Conference 2015
 
Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...
Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...
Demo the reactive jargons by Mushtaq Ahmed, ThoughtWorks presented at Pune Sc...
 
Demo the reactive jargons
Demo the reactive jargonsDemo the reactive jargons
Demo the reactive jargons
 
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
 
An Abusive Relationship with AngularJS
An Abusive Relationship with AngularJSAn Abusive Relationship with AngularJS
An Abusive Relationship with AngularJS
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Ipc feb4
Ipc feb4Ipc feb4
Ipc feb4
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
The art of concurrent programming
The art of concurrent programmingThe art of concurrent programming
The art of concurrent programming
 
smalltalk numbercrunching
smalltalk numbercrunchingsmalltalk numbercrunching
smalltalk numbercrunching
 
Barcamp presentation
Barcamp presentationBarcamp presentation
Barcamp presentation
 
IoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
IoTivity Tutorial: Prototyping IoT Devices on GNU/LinuxIoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
IoTivity Tutorial: Prototyping IoT Devices on GNU/Linux
 
Free the Functions with Fn project!
Free the Functions with Fn project!Free the Functions with Fn project!
Free the Functions with Fn project!
 
jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...
jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...
jSession #4 - Maciej Próchniak - Java 9, OSGi - czy w epoce mikroserwisów pot...
 
Voxxed Days Villnius 2015 - Burning Marshmallows
Voxxed Days Villnius 2015 - Burning MarshmallowsVoxxed Days Villnius 2015 - Burning Marshmallows
Voxxed Days Villnius 2015 - Burning Marshmallows
 

Último

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 

Último (20)

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 

Event Driven with LibUV and ZeroMQ

  • 1. Event Driven with LibUV and ZeroMQ Phase I Summary Luke.jf.luo@gmail.com
  • 2. Outline ● Algo Trading Business Flow Review ● Order Module Design: Current Flaw ● Distributed System: Theory Review ● Event Driven System: Review ● Event Driven Design In Algo Trading ● Project Plan
  • 3. Algo Trading Flow I1 I2 I3 …... In 任务 ( 下达 / 取消 / 停止 ) Instrument (Buy/Sell) 下单 撤单 下单 撤单 步长步长 . . . ... ... …......... ... ... …......... ... ... …......... End …............
  • 4. Current Design Flaw ● Bad Assumptions – Serial Execution Among Instructments – Batch Job ( 1 Sec Interval) – I/O Cost/ Latency: Neglectable – Computation Cost/Latency: Neglectable – No Uncertainty
  • 5. Reality ● Parallel execution of Instruments ● Market change in Ms, 1 Sec (or More) fixed reponse interval is 1000X ● I/O is SLOW comaring to CPU speed (10^9 order) ● Communication Channel will Break ● Only God have ALL TIMELY information for decision making. We people live in UNCERTAINTY ● Tradeoff: Best Effort Decision versus Perfect Decision
  • 6. Distributed System: Our Reality ● Parallel: Everything is Moving ● Error Prone (Fault): No 99.9999999....% Gurantee ● Uncertainty: Who/What/Where/When/Why ● Concensus/Consistency with HIGH COST ● Speed limit: Light Travels at (300,000km/Sec)
  • 9. Case:Two Generals' Problem ● 1975 . E. A. Akkoyunlu, K. Ekanadham, and R. V. Huber "Some Constraints and Trade-offs in the Design of Network Communications" ● “A pragmatic approach to dealing with the Two Generals' Problem is to use schemes that accept the uncertainty of the communications channel and not attempt to eliminate it, but rather mitigate it to an acceptable degree.”
  • 12. Event Driven: History ● 1960s: Mainframe. Batch Job Oriented ● 1970s: Unix. Interactive,Timesharing Terminal ● GUI programming: – Xerox : mouse – Apple: Apple II – Microsoft: Windows – MIT: X windows – …...
  • 13. Event Driven: Now ● Libuv: Chrome browser, node.js... ● Libev/libevent ● Boost ASIO ● ACE/ICE ● Qt event loop ● Glib/Gevent
  • 14. Event Driven: Now ● Nginx,apache,Twisted,Comet ● Node.js ● Python Asyncio ● Go channel ● Scala Actor ● C++ 11 Promise/Future,Coroutine,Closure ● …........
  • 15. I/O Modelling ●  blocking I/O ●  nonblocking I/O ●  I/O multiplexing (select and poll) ●  signal driven I/O (SIGIO) ●  asynchronous I/O (the POSIX aio_functions) Quoted from “UNIX Network Programming Volume 1”
  • 16.
  • 18.
  • 20.
  • 21. So we are event-driven ready. But... ● Components are mostly event driven ● Interface Among components are BLOCKING INTERFACE! (block/wait/timeout....) ● One blocking will ruin the whole infrastructure! ● “Public Land Tragic”
  • 22. class StringQue : public MsgQueBase
  • 23. StringQueue is everywhere [luke@rmbp service_multichannel]$ find . -name StringQue.h ./orderservice/OMSInfterfaceDemo/StringQue.h ./optionhedgeservice/optionhedgeservice/StringQue.h ./queryservice/queryservice/StringQue.h ./queryservice/queryservice_auto_qt_profitchart/StringQue.h ./queryservice/queryservice_auto_qt/StringQue.h ./strategyservice_new/hedgefutureservice/StringQue.h ./strategyservice_new/algoorderservice/StringQue.h ./strategyservice_new/algoorderserviceFuture/StringQue.h ./strategyservice/hedgefutureservice/StringQue.h ./strategyservice/optionhedgeservice/optionhedgeservice/StringQue.h ./strategyservice/algoorderservice/StringQue.h ./strategyservice/algoorderserviceFuture/StringQue.h ./quoteservice/quoteservicelevel2/StringQue.h ./quoteservice/quoteservicelevel2datafeed/StringQue.h ./quoteservice/quoteservicelevel2_new/StringQue.h ./quoteservice/quoteservicelevel2datafeed_clb/StringQue.h
  • 24. How we use StringQueue?
  • 25. Vision ● A fault tolerant, responsive trading platorm – Respond to every marktet tick/heartbeat ● Maintain “fresh” market snapshot ● React as every tick comes – Async, Parallel order fullfillment ● Handle > 1000 orders one server instance without pressure ● Milisec level processing delay per order action
  • 26. Vision: Unified Event Loop Libuv event Loop ZeroMq socket Normal socket timer Other Async events eventfd fd timer_t handle async_t handle Parallel Tasks req_t Thread Pool Async Tasks Order Fullfill Market Snapshot update Other Event Loop Other business modules
  • 27. Async Programming ● Callback ● Task(threading) ● Future/Promise ● Async I/O ● Coroutine ●
  • 28. Trading Version 2 I1 I2 I3 …... In 下单 撤单 下单 撤单 timeouttimeout . . . ... ... ... ... …......... ... ... …......... End …............ tick …......... EndEndEnd tick tick tick
  • 29. Project Plan ● Goal: A testable new framwork – Algotrading as typical business test case – High throughput, low latency – Fault Tolerant with sensible tradeoff strategy Side by Side comparison with current order system
  • 30. Task: ● Project Managment (Wei Song) ● Event Loop, ZeroMQ (Tie Gang/Luke) ● Market snapshot update (Wei Song/Ze Yu) ● Order business module rewrite(Ze Yu/Wei Song) ● Testing environment (Wei Song/Tie Gang) – Simulation data/replay – OMS simulator ● Testing – All – + Calvin + other business staff
  • 31. Schedule? ● What can we accomplish before Spring Festival?