Enter AnyCable v1.4: reliable real-time features for apps of any size

Cover for Enter AnyCable v1.4: reliable real-time features for apps of any size

Translations

If you’re interested in translating or adapting this post, please contact us first.

We’re excited to announce the release of AnyCable 1.4! It comes with a slew of new features designed to enhance real-time applications. This version includes major improvements like Reliable Streams, Resumable Sessions, simplified Heroku deployment, long-polling fallback, enhanced Hotwire compatibility, and OCPP support. Read on for more details!

With the new additions in AnyCable 1.4, it’s now easy for us to recommend AnyCable for any application, even if your traffic and load are still manageable using Action Cable alone. The reliability and simplicity of running AnyCable have changed the game, making it the go-to choice from the very beginning of your project.

So, buckle up and let’s dive in!

Reliable streams and resumable sessions

Today, the need for dependable real-time data consistency is non-negotiable. However, Action Cable lacks this capability; it only provides at-most-once delivery guarantees. What does it mean? If a client is disconnected from the server (e.g., due to intermittent network failures), it misses all messages sent by server during the downtime:

A diagram showing client-server communication during re-connection.

AnyCable leaps forward by allowing clients to request missed messages upon reconnection, seamlessly restoring their state without the need for re-authentication or channel re-subscription. This is made possible through the extended version of the Action Cable protocol, which is supported out of the box by the AnyCable JS client. Yes, you read that right—no need to make any changes to your application-level code!

By implementing this feature, we’ve achieved optimal reliability without sacrificing the performance of real-time processing. Unlike other alternatives such as Action Cable and Pusher, AnyCable provides an unparalleled level of dependability for your real-time data and updates.

Creating a delicate cooperation between the server and the client was no easy task. We wanted to ensure the restoration of any missed data and guarantee exactly-once delivery. And that’s precisely what we’ve achieved in version 1.4.

The official Rails Action Cable protocol lacks message IDs and acknowledgment mechanisms, so, to make this work, we extended the protocol. By adding these essential components at the protocol level, we’ve baked reliability to the foundation for all applications.

For single-node setups, our open-source version now supports reliability and resumability. And for those eyeing cluster mode support, our Pro version is here for you! Simply equip your setup with the AnyCable JS client and make a few configuration tweaks—that’s all you need to ensure that your end users receive the right data in the correct order, every time.

This feature also brings reliability to Hotwire, a major “HTML over-the-wire” framework. When using Hotwire, you won’t need to write any JS or Ruby code for Action Cable, allowing you to maintain the same developer experience while ensuring consistency in Turbo Streams.

AnyCable is no longer only a performance boost for Action Cable, but an independent project providing unique and valuable features. That’s why we say this is a new era for AnyCable. As a result, our focus is no longer solely on compatibility with Action Cable; AnyCable has become a superset of Action Cable, expanding its capabilities.

Simplified mode for Heroku and other platforms: RPC over HTTP

With the introduction of a special HTTP mode in AnyCable, deploying to platforms like Heroku, and other serverless providers has never been easier. This update unlocks a new world of possibilities.

Initially, AnyCable was designed to maximize performance for large-scale systems with tens of thousands of concurrent users broadcasting and receiving streams of real-time data. Its power lies in the fact that WebSockets, the transport mechanism for these data streams, are handled by a separate server called AnyCable-Go, alleviating the load on your main web application.

AnyCable-Go quietly hums along until a client sends a command related to business logic, which needs to be escalated back to the main application. This is where remote procedure calls (RPC) come into play. AnyCable-Go utilizes RPC to call a method from the main application.

For years, AnyCable relied on performant gRPC as the underlying RPC mechanism. However, using gRPC requires running a separate instance of the main application to serve HTTP2 traffic. This complicates the infrastructure, especially on platforms that don’t support HTTP2, such as Heroku, where running AnyCable in full mode can be a bit tricky.

But worry no more! With the new RPC over HTTP mode, you can embed AnyCable’s RPC functionality directly into your main app, a Rails server. No additional services or ports required.

You might ask, “but what about the difference in performance?” It’s not as significant as you (or, we) might think. We’ve conducted tests using websocket-bench, and AnyCable outperforms Action Cable by a wide margin, even in HTTP mode. Therefore, we highly recommend trying out the simplified mode, especially for applications with less than a thousand concurrent connections.

Benchmark results comparing round-trip time latency

Now, to make deployment even simpler, we’ve finally added a “Deploy to Heroku” button. Deploying to Heroku is now just a few clicks away!

And, although we’ve built this feature with Heroku in mind, it opens up many other possibilities. Just imagine using AnyCable as a real-time server for your serverless apps (where HTTP RPC handlers are implemented as edge or serverless functions)—sounds cool, right?

Long-polling fallback

In our efforts to accommodate more use cases, we’re introducing long-polling fallback support for AnyCable Pro. This feature is particularly useful for applications running behind corporate proxy servers and firewalls that block WebSockets. For example, this is the case for many e-health applications that rely on AnyCable to power up their chat and communication functionality while ensuring that all sensitive medical data remains on-premise.

We considered various fallback options for scenarios involving restrictive firewalls, including Server-Sent Events. However, browser requirements made the decision for us. Since we wanted to support IE10+, long polling emerged as the best choice; AnyCable Pro is now ready to navigate firewalls.

But we’re not stopping there! AnyCable aims to live up to the “any” in its name. In the near future, we plan to add support for Server-Sent Events (SSE) and explore other exciting possibilities.

Previously, Rails applications utilizing Hotwire could already leverage the power of AnyCable for scalable “HTML over-the-wire”. Now, we’re taking it one step further—you don’t even have to be using Rails! AnyCable is fully primed and ready to supercharge any Hotwire-based application.

Check out our non-Rails guide for more information.

OCPP support

The world of real-time web goes beyond humans and Martians. Today, our customers can utilize AnyCable for real-time communication with electric vehicle (EV) chargers. We’re excited to meet the future head-on, which is why we added support for OCPP (Open Charge Point Protocol), a popular standard for charger-to-server communication.

Now, imagine the following scenario:

  • A driver encounters difficulties starting a charging session and contacts tech support over the phone.
  • A Twilio Stream is created, transmitting audio over a WebSocket to a cable application where we perform text-to-speech analysis and identify the driver’s request (“please start my charging session”).
  • An OCPP command is sent via a WebSocket connection to the charger, initiating a remote transaction.

With Rails and AnyCable, you can now implement this scenario seamlessly!

A diagram showing how AnyCable can be used to commicate with EV chargers via OCPP

AnyFuture

We’re looking beyond the horizon, to a place where IoT and devices sending all kinds of real-time data have become popular use cases for AnyCable!

The AnyCable 1.4 release is packed with exciting features that amplify your real-time application’s reliability and efficiency. We’re committed to continually pushing the boundaries of what’s possible. Stay tuned for more!

Bonus: what we learned

In v1.4, we implemented two features largely due to commercial support from our customers. Both features were crucial for their operations and fit nicely with our product strategy, but were caught in our extensive backlog.

As an experiment, we proposed to financially back the development of these features. To our delight, customers agreed. We provided the cost estimates and prioritized these tasks.

This strategy resulted in a win-win situation: the customers received their much-needed functionality, and we had solid proof of the feature’s value for our user base.

That said, it’s crucial to mention that this doesn’t mean our entire product strategy is customer-funded. Occasionally, this strategy can be a nice way to deal with backlog prioritization while helping ensure the sustainability of our business.

We believe this approach might be a worthwhile consideration for other software businesses with similar challenges. As always, we’re learning as we grow, and we’re committed to sharing those lessons with our community.

At Evil Martians, we transform growth-stage startups into unicorns, build developer tools, and create open source products. If you’re ready to engage warp drive, give us a shout!

To get AnyCable (any part of it), just visit anycable.io.

Join our email newsletter

Get all the new posts delivered directly to your inbox. Unsubscribe anytime.

In the same orbit

How can we help you?

Martians at a glance
17
years in business

We transform growth-stage startups into unicorns, build developer tools, and create open source products.

If you prefer email, write to us at surrender@evilmartians.com