Overview of ZeroMQ

77,050 views

Published on

Overview of ZeroMQ by Pieter Hintjens, CEO of iMatix Corporation.

Published in: Technology, Education
2 Comments
65 Likes
Statistics
Notes
No Downloads
Views
Total views
77,050
On SlideShare
0
From Embeds
0
Number of Embeds
1,105
Actions
Shares
0
Downloads
1,035
Comments
2
Likes
65
Embeds 0
No embeds

No notes for slide

Overview of ZeroMQ

  1. 1. Introduction to ZeroMQ 1 December 2011 Pieter Hintjens, iMatix
  2. 2. Why did we need ØMQ? <ul><li>Moore's Law means more moving pieces
  3. 3. Cost of connecting pieces was too high </li><ul><li>Custom TCP or UDP
  4. 4. Broker-based messaging
  5. 5. Clumsy RPC solutions </li></ul><li>We needed cheaper connectivity
  6. 6. It had to be really fast and really simple </li></ul>
  7. 7. What is ØMQ? <ul><li>Intelligent socket library for messaging
  8. 8. Many kinds of connection patterns
  9. 9. Multiplatform, multi-language (30+)
  10. 10. Fast (8M msg/sec, 30usec latency)
  11. 11. Small (20K lines of C++ code)
  12. 12. Open source LGPL (large community) </li></ul>
  13. 13. ØMQ Hello World import org.zeromq.ZMQ; public class hwclient { public static void main (String[] args){ ZMQ.Context context = ZMQ.context (1); ZMQ.Socket socket = context.socket (ZMQ.REQ); socket.connect (&quot;tcp://localhost:5555&quot;); socket.send (&quot;Hello&quot;, 0); System.out.println (socket.recv(0)); } } import org.zeromq.ZMQ; public class hwserver { public static void main (String[] args) { ZMQ.Context context = ZMQ.context(1); ZMQ.Socket socket = context.socket(ZMQ.REP); socket.bind (&quot;tcp://*:5555&quot;); while (true) { byte [] request = socket.recv (0); socket.send(&quot;World&quot;, 0); } } }
  14. 14. Request-Reply Pattern
  15. 15. Publish-Subscribe Pattern
  16. 16. Pipeline Pattern
  17. 17. Simple ØMQ Application
  18. 18. ØMQ Transports <ul><li>Threads in one process (inproc://)
  19. 19. Processes on one box (ipc://)
  20. 20. Processes on one network (tcp://)
  21. 21. Multicast group (pgm://) </li></ul>
  22. 22. Multihop ØMQ Application
  23. 23. Typical ØMQ Design
  24. 24. ØMQ Routing <ul><li>Round-robin (REQ, PUSH, DEALER)
  25. 25. Multicast (PUB)
  26. 26. Fair-queuing (REP, SUB, PULL, DEALER)
  27. 27. Explicit addressing (ROUTER)
  28. 28. Unicast (PAIR) </li></ul>
  29. 29. ØMQ Features <ul><li>Message blobs of 0 to N bytes
  30. 30. One socket connect to many sockets
  31. 31. Queuing at sender and receiver
  32. 32. Automatic TCP (re)connect
  33. 33. Zero-copy for large messages </li></ul>
  34. 34. ØMQ for Multithreading <ul><li>Don't use locks, semaphores, mutexes
  35. 35. Design app as message-driven tasks
  36. 36. Each task reads from 1..n sockets
  37. 37. Tasks can talk over inproc://
  38. 38. Tasks can be split into processes over tcp://
  39. 39. No wait states, no locks, full CPU use
  40. 40. Scalable to any number of cores </li></ul>
  41. 41. ØMQ Benefits <ul><li>Start with simple / fast language (Python)
  42. 42. Move to faster language where needed (C)
  43. 43. Run on arbitrary platforms (Windows, Android)
  44. 44. Scale to arbitrary sizes (2 cores, 16 cores...)
  45. 45. No per-core or per-seat licensing
  46. 46. Easy to experiment and learn </li></ul>
  47. 47. Working with ØMQ <ul><li>Rapid prototyping of main components
  48. 48. Small protocols for main flows
  49. 49. ØMQ patterns for main flows
  50. 50. Break components up for performance
  51. 51. Profile and test
  52. 52. Improve incrementally over many cycles </li></ul>
  53. 53. ØMQ Origins <ul><li>iMatix history of enterprise middleware
  54. 54. 2004 – AMQP standard for JPMorganChase
  55. 55. 2005 – OpenAMQ message broker/client
  56. 56. 2008 – ØMQ/0.x for the avant-garde
  57. 57. 2009 – ØMQ/1.x for pioneers (finance)
  58. 58. 2010 – ØMQ/2.x for early adopters (foss)
  59. 59. 2011 – ØMQ/3.x for mass market (cloud) </li></ul>
  60. 60. ØMQ Community <ul><li>Large, 24/7 community of experts
  61. 61. 1,000 people on dev list, 120 on IRC
  62. 62. Responsible for everything: </li><ul><li>Core development & packaging
  63. 63. Language bindings (35 or more)
  64. 64. Events and presentations </li></ul><li>ØMQ is 100% owned by the community </li><ul><li>Which iMatix is a happy part of </li></ul></ul>
  65. 65. ØMQ Resources <ul><li>www.zeromq.org – main web site
  66. 66. zero.mq – community wiki
  67. 67. #zeromq – IRC channel on Freenode
  68. 68. zeromq-dev – email list on zeromq.org
  69. 69. github.com/zeromq – git repositories
  70. 70. zguide.zeromq.org – user guide
  71. 71. api.zeromq.org – reference manual </li></ul>

×