ScalingCometD to The Masses<br />by Kevin Nilson<br />Principal Architect / E*Trade Financial<br />
LearnaboutCometD and ScalingCometDApps<br />
Agenda<br />Quick Intro to CometD<br />Basic Steps (OutsideCometD)<br />Advanced Steps (InsideCometD)<br />
Kevin Nilson<br />Java Champion<br />Co-authored Web 2.0 Fundamentals Book<br />Leader Silicon Valley Web Developer JUG<br...
Intro To CometD<br />What’s Comet? <br />What’s Bayeux?<br />What’s CometD? <br />Pushing Data to The Net over HTTP<br />C...
DEMO<br />Polling Interal<br />
Polling<br />
Long Polling<br />
Streaming<br />
Basic Steps (OutsideCometD)<br />Reduce overhead<br />Allow Multithreading<br />Remove Simple Bottlenecks<br />
Remove Apache<br />Apache Has 1 Thread Per Request Limit<br />Browse<br />Apache<br />Jetty<br />
Separate Client Into Tiers<br />Some high throughput some low<br />Spreads broadcast over multiple threads<br />Delivery t...
Only Deliver Changed Fields<br />50% Field Delivery Reduction<br />
Advanced Steps<br />Move Customers to slower tier if they are not consuming fast enough<br />Disconnect users with very “l...
Before, No InternalVisiblity<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />LEDGEND<br />I can see<b...
Before – Full Story<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />LEDGEND<br />I can see...
After<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />DeliverListener<br />QueueListener<b...
Queue & Deliver Listener Code<br />client.addListener(newQueueListener() {<br />	public booleanqueueMaxed(Client client, C...
Prevent Huge Queue<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />Check Queue Size:<br />...
Measure Average Time in Queue<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />Check Time I...
Adjust Tier: Avg Queue Size of Client<br />Platinum<br />Gold<br />Silver<br />Bronze<br />JMS<br />MyBayeuxService<br />P...
Broadcast in CometD, not JMS<br />JMS<br />MyBayeuxService<br />Browser<br />Browser<br />Browser<br />JMS<br />MyBayeuxSe...
Channel Create & RemoveListener<br />JMS<br />MyBayeuxService<br />channelAdded<br />channelRemoved<br />
ChannelBayeuxListener Code<br />bayeux.addListener(newChannelBayeuxListener() {<br />	public void channelAdded(Channel cha...
Adjust Tier Rate based on Avg Queue Size<br />Platinum<br />Gold<br />Silver<br />Bronze<br />JMS<br />MyBayeuxService<br ...
Auto Throttle: Avg Message Delay<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />Platnium	...
Summary<br />CometD Intro<br />Basic Steps<br />Advanced Steps<br />. . .<br />
Thanks<br />kevin_nilson@dev.java.net<br />Web2-book.com - Web2.0 Fundamentals<br />
Upcoming SlideShare
Loading in …5
×

Scaling CometD by Kevin Nilson

2,186 views

Published on

Scaling CometD by Kevin Nilson at Java User Group Chennai

http://www.jugchennai.in/2011/05/16/web-2-0-with-kevin-nilson-14-may-2011-tenth-planet/

http://www.jugchennai.in

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,186
On SlideShare
0
From Embeds
0
Number of Embeds
704
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Scaling CometD by Kevin Nilson

  1. 1. ScalingCometD to The Masses<br />by Kevin Nilson<br />Principal Architect / E*Trade Financial<br />
  2. 2. LearnaboutCometD and ScalingCometDApps<br />
  3. 3. Agenda<br />Quick Intro to CometD<br />Basic Steps (OutsideCometD)<br />Advanced Steps (InsideCometD)<br />
  4. 4. Kevin Nilson<br />Java Champion<br />Co-authored Web 2.0 Fundamentals Book<br />Leader Silicon Valley Web Developer JUG<br />Lead Silicon Valley Google Tech User Group<br />Leader Silicon Valley JavaScript Meetup<br />Taught 7 Courses College Of San Mateo<br />Winner of MySpace Editor's Choice Award for project YumieDate, at Open Social Weekend Apps hosted at Google<br />
  5. 5. Intro To CometD<br />What’s Comet? <br />What’s Bayeux?<br />What’s CometD? <br />Pushing Data to The Net over HTTP<br />Channel & JSON Based Comet Protocol<br />Comet Client and Server Implementation using Bayeux<br />What’s WebSockets?<br />
  6. 6. DEMO<br />Polling Interal<br />
  7. 7. Polling<br />
  8. 8. Long Polling<br />
  9. 9. Streaming<br />
  10. 10. Basic Steps (OutsideCometD)<br />Reduce overhead<br />Allow Multithreading<br />Remove Simple Bottlenecks<br />
  11. 11. Remove Apache<br />Apache Has 1 Thread Per Request Limit<br />Browse<br />Apache<br />Jetty<br />
  12. 12. Separate Client Into Tiers<br />Some high throughput some low<br />Spreads broadcast over multiple threads<br />Delivery to 5 channels can be handled by 5 threads<br />Delivery to 1 Channel can be handled by only 1 thread<br />/Player/GameUpdate<br />High Volume<br />/GameUpdate<br />Publisher<br />/Watcher/GameUpdate<br />Low Volume<br />
  13. 13. Only Deliver Changed Fields<br />50% Field Delivery Reduction<br />
  14. 14. Advanced Steps<br />Move Customers to slower tier if they are not consuming fast enough<br />Disconnect users with very “large” queues<br />Auto adjust throttling if overall we are producing faster than we can consume (deliver to customers)<br />
  15. 15. Before, No InternalVisiblity<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />LEDGEND<br />I can see<br />I can’t see<br />
  16. 16. Before – Full Story<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />LEDGEND<br />I can see<br />I can’t see<br />
  17. 17. After<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />DeliverListener<br />QueueListener<br />LEDGEND<br />I can see<br />I can’t see<br />
  18. 18. Queue & Deliver Listener Code<br />client.addListener(newQueueListener() {<br /> public booleanqueueMaxed(Client client, Client client1, Message arg2) {<br /> … <br /> }<br />}<br />client.addListener(newDeliverListener( ) {<br /> public void deliver(Client arg0, Queue<Message> queue) { <br /> …<br /> }<br />}<br />
  19. 19. Prevent Huge Queue<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />Check Queue Size:<br />Disconnect Client if “Large”<br />LEDGEND<br />I can see<br />I can’t see<br />
  20. 20. Measure Average Time in Queue<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />Check Time In Queue:<br />Move Client to Slower Tier or Increase Overall Throttling<br />LEDGEND<br />I can see<br />I can’t see<br />
  21. 21. Adjust Tier: Avg Queue Size of Client<br />Platinum<br />Gold<br />Silver<br />Bronze<br />JMS<br />MyBayeuxService<br />Platinum = 100 updates / minute<br />Gold = 50 updates / minute<br />Silver = 25 updates / minute<br />Bronze = 10 updates / minute<br />LEDGEND<br />
  22. 22. Broadcast in CometD, not JMS<br />JMS<br />MyBayeuxService<br />Browser<br />Browser<br />Browser<br />JMS<br />MyBayeuxService<br />Browser<br />Browser<br />Browser<br />
  23. 23. Channel Create & RemoveListener<br />JMS<br />MyBayeuxService<br />channelAdded<br />channelRemoved<br />
  24. 24. ChannelBayeuxListener Code<br />bayeux.addListener(newChannelBayeuxListener() {<br /> public void channelAdded(Channel channel) {<br /> // Code Here<br /> }<br /> public void channelRemoved(Channel channel) {<br /> // Code Here<br /> } <br />});<br />
  25. 25. Adjust Tier Rate based on Avg Queue Size<br />Platinum<br />Gold<br />Silver<br />Bronze<br />JMS<br />MyBayeuxService<br />Platinum = 100 updates / minute<br />Gold = 50 updates / minute<br />Silver = 25 updates / minute<br />Bronze = 10 updates / minute<br />Platinum = 50 updates / minute<br />Gold = 25 updates / minute<br />Silver = 10 updates / minute<br />Bronze = 5 updates / minute<br />LEDGEND<br />
  26. 26. Auto Throttle: Avg Message Delay<br />filter<br />Jetty<br />JMS<br />BayeuxService<br />Browser<br />Queue<br />Platnium = 50 updates <br />Gold = 25 updates<br />Silver = 10 updates<br />Bronze = 5 updates<br />Platnium = 100 updates <br />Gold = 50 updates<br />Silver = 25 updates<br />Bronze = 10 updates<br />LEDGEND<br />
  27. 27. Summary<br />CometD Intro<br />Basic Steps<br />Advanced Steps<br />. . .<br />
  28. 28. Thanks<br />kevin_nilson@dev.java.net<br />Web2-book.com - Web2.0 Fundamentals<br />

×