DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. A Lightweight Alternative to ApacheMQ or RabbitMQ: OCamlMQ

A Lightweight Alternative to ApacheMQ or RabbitMQ: OCamlMQ

Mitch Pronschinske user avatar by
Mitch Pronschinske
·
Aug. 18, 10 · Interview
Like (0)
Save
Tweet
Share
18.40K Views

Join the DZone community and get the full member experience.

Join For Free
ocamlmq is a messaging system written in OCaml (as you might have guessed) but it can be used with virtually any language (a STOMP protocol) implementation is required).  It has a small footprint and it was written using around 1,200 lines of code.  The message broker's author, Mauricio Fernández, says that ocamlmq is especially suitable for creating task queues and communication between subsystems.

Because ActiveMQ and RabbitMQ (with STOMP adapters) didn't work the way Fernández needed, he created created ocamlmq.  The problems he ran into included excessive memory footprint, performance issues with ApacheMQ's scalable storage backends (KahaDB, JDBC), and performance issues with RabbitMQ's topic message dispatch.  Fernández says the memory footprint for ocamplmq is under 3MB at startup while ApacheMQ is over 120MB.  He also mentions that RabbitMQ was doing a linear scan of the subscription table per dispatch during its topic message dispatch.

ocamlmq can scale over arbitrarily large numbers of queues with constant memory usage, and it also has strong message saving guarantees.  It features message priorities and a per-subscription prefetch limit for queue messages.  There is error handling and ACK timeout, so if a subscriber doesn't ACK a message after its timeout, the message will be sent to a different subscriber.  If a subscriber dies and its connection expires, messages will also be re-sent automatically.

Millions of subscriptions cause no problems for ocamlmq.  It also has topic subscriptions with prefix matching, and simple extensions within the STOMP protocol that can report the number of messages in a queue and the subscribers to a queue or topic.  ocamlmq does have a few limitations outside of its intended domain, which is persistent queues and transient topic destinations.  It's not designed to perform well when scaled beyond a thousand simultaneous connections and there is no flow control for topic messages (in the proper use case, topics are small and processed fast).  ocamlmq currently implements PostgreSQL's backend which can only persist a few thousand messages per second, but it allows message bursts of more than 50k per second in async mode.  It also doesn't allow very high message rates (20k/s on 3GHz AMD64).

However, ocamlmq is highly scalable, and it can support millions of queues and topic subscriptions with a low memory footprint.  It usually only needs around 150 bytes per subscription.  Remember, ActiveMQ requires 120MB on startup.  Queries have no additional memory cost, so you are free to use plenty without regard for memory.

The ocamlmq source code can be found on GitHub.  You'll need a working OCaml environment and three other libraries.
Memory (storage engine) Flow control (data) Message broker Timeout (computing) Protocol (object-oriented programming) OCaml Database Connection (dance)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Microservices Testing
  • What Are the Different Types of API Testing?
  • A Gentle Introduction to Kubernetes
  • NoSQL vs SQL: What, Where, and How

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: