High Performance Messaging for Web-Based Trading Systems

High Performance Messaging for Web-Based Trading Systems

High Performance Messaging for Web-based Trading Systems Frank Greco - @frankgreco Director of Technology, Kaazing Outline § Background § Trading Systems and the Web § Requirements § Web Messaging for Trading Apps § Layered Approach to Web Protocols § New Requirements § The Web beyond the Browser © 2013 Kaazing Corporation Background § Financial Services – Capital Markets § Desktop trading systems – Swing/Java/TIBCO, et al § Customer use cases – FX, Commodity desks § Director of Technology @ Kaazing § Chairman NYJavaSIG (javasig.com) § Largest JUG in North America 7,000+ members § [email protected], @frankgreco © 2013 Kaazing Corporation Web Trading Systems FX Trader Application – front office demo.kaazing.com/forex © 2013 Kaazing Corporation What is a Web Trading System § Trading System – A set of rules governing buying/selling § An application that expedites a trading system § Modern Web Trading requirements - HTML5 – no more plugins - UI/UX – Sencha/extJS, GWT, jQuery, GPU acceleration, etc - Usable application cache - Fast, reliable, secure - Minimal impact to back-end services - Works with pub/sub brokers and data feeds - High message rate, small payload – equity ticks, watchlist, currency pairs, etc. © 2013 Kaazing Corporation Everything sounds do-able, except… § Designed for document transfer – HTTP - Short-lived Request / Response interaction § Bidirectional, but half-duplex - Traffic flows in only one direction at a time § Stateless - Large amounts of metadata resent for each request Web was not designed for “real-time”, event-based services… © 2013 Kaazing Corporation Some things age well… HTTP TCP © 2013 Kaazing Corporation …and some things don’t Oldies Hits - AJAX and the Comet Pollers - 2006 © 2013 Kaazing Corporation High-Level Trading Systems Architecture iOS/Android Pricing Feeds Mobile Authentication Authorization Browser/Native Client Make Net me Msg News/Alerts Web Broker friendly Browser JMS/AMQP etc… Trade Exec What everyone does… Desktop Java/.NET Reports © 2013 Kaazing Corporation High-Level Trading Systems Architecture iOS/Android Pricing Feeds Mobile Authentication Authorization Browser/Native Client Make Net me Msg News/Alerts Web Broker friendly Browser JMS/AMQP etc… Trade Exec Developers want a secure version of this Desktop architecture so they Java/.NET can focus on the app Reports © 2013 Kaazing Corporation Real-time Client/Server Architecture Instead, we try this traditional solution Trading App Broker Just have to open some ports… Merely deploy Java/.NET on Only need to traverse several client… proxies between the endpoints… Easy, right?... © 2013 Kaazing Corporation Middleware for the Middleware Or we try to proxy things over the web ticker plant Scalability Issues… Protocol mismatches… Inefficient… Latency Issues… © 2013 Kaazing Corporation Things aren’t looking too good… © 2013 Kaazing Corporation Welcome HTML5 (aka The New Web)! § Users are Demanding more from Apps § UI/UX Requirements are more sophisticated § API Explosion § Browser Enhancements § Web no longer just about Documents but the existing infrastructure reflects this legacy The New Web is a Foundation for Enterprise-grade Applications 14 © 2013 Kaazing Corporation WebSocket • “Real-Time”, bi-directional connectivity • IETF Protocol - RFC 6455 – Dec 2011 • W3C API • Easily add event-based (trading) data to web apps • Avoids polling • Avoids HTTP meta-data overhead • Shares port with HTTP (80/443) • Peer protocol to HTTP (both use TCP) • Most Important API in HTML5 • Facilitates other protocols • Puts the web in a better place… © 2013 Kaazing Corporation WebSocket Standards § W3C API – Candidate Recommendation - http://www.w3.org/TR/websockets/ § IETF Formal Protocol (RFC 6455) - Event-driven JavaScript API - Full-duplex communication protocol § Integrates HTTP addressing - ws://yourcompany.com/collaboration_svc - wss://anothercompany.com/marketdata_svc § Traverses firewalls, proxies, routers securely § Text and Binary § Leverages Cross-Origin Resource Sharing (CORS) © 2013 Kaazing Corporation The WebSocket Handshake © 2013 Kaazing Corporation For Real-Time, Event-based Web Communication… Legacy HTTP vs WebSocket Seems like a no-brainer for trading apps… 18 © 2013 Kaazing Corporation Java API for WebSocket - JSR 356 § Creation of WebSocket Java components to handle bi-directional WebSocket conversations § Handling WebSocket events § Creation and consumption of WebSocket text and binary messages § Allows for WebSocket protocols and content models for an application § Configuration and management of WebSocket sessions, like timeouts, retries, cookies, connection pooling § Specification of how WebSocket application will work within the Java EE security model! § Official Java SE WebSocket API in the works… © 2013 Kaazing Corporation Why do I Care? What does this really have to do with high- performance messaging? © 2013 Kaazing Corporation Legacy Web Half Duplex - HTTP Full duplex Web Browser Web Tier Middleware Msg Broker Live Web Full duplex - WebSocket Full duplex Web WebSocket Msg Broker Server © 2013 Kaazing Corporation Scalability – more traders, more services Complexity More Traders More Services More…More… Growth Greco’s Law! Scalability = Growth / Complexity Simple things scale… 22 © 2013 Kaazing Corporation 22 HTML5 WebSocket API © 2013 Kaazing Corporation HTML5 WebSocket API But… Dealing with WebSocket is like dealing with TCP. It’s a streams-based model. You need to understand how to handle streams-based data over the wire. So how do I do publish/subscribe for my trading system? © 2013 Kaazing Corporation What is Missing? Where is the Application-level Protocol? • Who handles retries? • How do we handle publish/subscribe semantics? • How do we handle market data? • Is guaranteed delivery possible (trades)? • What if the client is not active? • How do we handle [fill in with favorite semantics] • What about partials? • Who’s responsible for entitlements? How do I manage that? • etc… © 2013 Kaazing Corporation But wait… Protocol Layering is Possible! Whoa… Its just like TCP! Huzzah! Browser and Native Applications JMS XMPP AMQP B2B FTP VNC mktdata etc WebSocket TCP Internet WebSocket WebSocket Gateway Gateway © 2013 Kaazing Corporation Anything Else Missing? Other Considerations… • Need to handle multiple WS versions • Need to handle multiple (and legacy) browser versions • Can’t have business logic in the DMZ • Have to work in multiple DMZs • AuthN/AuthZ has to work multiple times • High-availability topology • Concerns about open ports with back-end service • Services architecture needs to be consistent • Native, HTML5 and hybrid environments • Integrate easily with non-messaging services • XaaS integration – the Web beyond the browser • Bandwidth management • etc… All things you need for a real enterprise app © 2013 Kaazing Corporation Publish/Subscribe over the Web for Trading Systems Java Message Service (JMS) over WebSocket A 60-second Tutorial In case you haven’t heard of JMS… © 2013 Kaazing Corporation Java Message Service (JMS) • Java EE Message Oriented Middleware • JMS 1.0 2001, JMS 1.1 2002, JMS 2.0 (Feb 26, 2013) • Asynchronous Messaging vs. RPC • Loosely coupled vs. Tightly coupled • Pub/Sub, Topics, Queues • Transactions, Reliable © 2013 Kaazing Corporation Basic Inside-the-Firewall JMS conn = createConnection(); sess = conn.createSession(); topic = jndiContext.lookup(topic); pub = sess.createProducer(topic); pub.send(“hey Frank”); conn = createConnection(); sessconn = conn.createSession();= createConnection(); sessconn = conn.createSession();= createConnection(); topicsess = jndiContext.lookup(topic); = conn.createSession(); subtopic = sess.createConsumer(topic);= jndiContext.lookup(topic); subtopic = sess.createConsumer(topic);= jndiContext.lookup(topic); sub.setMessageListener(this);sub = sess.createConsumer(topic); …sub.setMessageListener(this); …sub.setMessageListener(this); public… void onMessage(Message m) { publicString voids = m.getText(); onMessage(Message m) { msg publicString voids = m.getText(); onMessage(Message m) { … doString stuff s… = m.getText(); broker } … do stuff… } … do stuff… } © 2013 Kaazing Corporation Now… JMS API for JavaScript 1. Create connection from ConnectionFactory see tutorial.kaazing.com 2. Create session 3. Create topic or queue 4. Create producer 5. Create consumer 6. Create message listeners (function to handle messages) 2 session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 3 var myTopic = session.createTopic("/topic/myTopic"); 4 topicProducer = session.createProducer(myTopic); 5 topicConsumer = session.createConsumer(myTopic); 6 topicConsumer.setMessageListener(handleTopicMessage); © 2013 Kaazing Corporation JMS API for JavaScript 7. Send messages var doSend = function(message) { message.setStringProperty(MESSAGE_PROPERTIES.userId, userId); topicProducer.send(null, message, DeliveryMode.NON_PERSISTENT, 3, 1, function() sendFromQueue(); }); }; 8. Process messages: the message listener function: handleTopicMessage() var handleTopicMessage = function(message) { if (message.getStringProperty(MESSAGE_PROPERTIES.userId) != userId) { $("#slider").val(message.getText()); $("#pic").width(message.getText()); } }; © 2013 Kaazing Corporation WebSocket Projects, OSS, Vendors • Kaazing • Node.js/socket.io • ActiveMQ • Tomcat • Jetty • Oracle Glassfish • Java EE • Play Framework • Rabbit MQ • JBoss • IIS/ASP .NET 4.5 • PHP, Objective-C, Ruby, Python, C/C++, JVM-langs… • Many more… © 2013 Kaazing Corporation Futures What’s next for Trading Systems and the Web?

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    41 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us