<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Parsa Honarmand on Medium]]></title>
        <description><![CDATA[Stories by Parsa Honarmand on Medium]]></description>
        <link>https://medium.com/@parsa.honarmand_11227?source=rss-7bf0939c6f79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wm1PVA5V9OvvzL14</url>
            <title>Stories by Parsa Honarmand on Medium</title>
            <link>https://medium.com/@parsa.honarmand_11227?source=rss-7bf0939c6f79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:28:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parsa.honarmand_11227/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Improving WebSocket performance at Clio]]></title>
            <link>https://medium.com/clio-labs/improving-websocket-performance-at-clio-b4c284a79ef9?source=rss-7bf0939c6f79------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4c284a79ef9</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[clio]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Parsa Honarmand]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 14:45:37 GMT</pubDate>
            <atom:updated>2024-11-29T14:45:37.746Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://medium.com/u/7bf0939c6f79">Parsa Honarmand</a> and <a href="https://medium.com/u/25275e325281">Dan Bird</a></h4><p>This blog post describes how members of several different teams at Clio worked together to improve poor WebSocket performance in Clio Manage, our flagship product.</p><p>Many software developers at Clio belong to one or more teams. Some of these teams are created by Clio’s upper-level management. Others are more ad-hoc and organized by individual contributors or front-line managers. Each team is responsible for improving their team’s <em>domain</em>. Examples of domains include Clio’s personal injury add-on, which helps personal injury lawyers work more efficiently, and also backend infrastructure, which includes software services that Clio uses to build its products.</p><p>Sometimes several teams are involved in fixing a problem. That’s what happened in October 2024 when one of Clio’s personal injury teams noticed a problem with WebSocket performance. Software developers and managers from team Personal Injury 2, Backend Infrastructure, and Production Engineering, as well as several other teams, discovered the cause of poor WebSocket performance, identified solutions, and implemented them.</p><p>Soon after launching a new feature that generates settlement statement documents for personal injury lawyers, team Personal Injury 2 noticed a problem. Certain buttons (shown below) took up to 20 seconds to become active after a page refresh — though at other times, these buttons were enabled within a second.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2GlQTujWTMyx-LFF" /></figure><p>These buttons remain inactive while the page establishes subscriptions to two <a href="https://anycable.io/">AnyCable</a> channels. AnyCable, our chosen WebSocket solution, is a drop-in replacement for Rails’ default <a href="https://guides.rubyonrails.org/action_cable_overview.html">Action Cable</a> library. To enable these buttons, AnyCable requires a handshake: a WebSocket message from the frontend initiates the subscription, and the backend confirms it by sending a return message.</p><p>What was causing the buttons to sometimes take up to 20 seconds to enable? As we investigated, a critical clue appeared in the following <a href="https://www.datadoghq.com/">Datadog</a> graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/0*8lZHKEzs2LplHVTG" /></figure><p>The graph above shows that a metric named <a href="https://github.com/anycable/anycable-go/blob/005350edbe1f80f0f41ed8ba531d23b3c1e3c459/docs/instrumentation.md?plain=1#L35">anycable_go.rpc_pending_num</a> was elevated at the same time that the buttons took a long time to become enabled. rpc_pending_num being elevated means there is a backlog of websocket messages waiting to be processed by <a href="https://github.com/anycable/anycable">the AnyCable gRPC server</a>. That server executes code written by Clio developers to process incoming WebSocket messages. When our code can’t process these messages quickly enough, AnyCable channel subscriptions are delayed, resulting in slower button activation.</p><p>After seeing the graph above we learned that the problem was more widespread than a single feature. Instead, all features in Clio Manage which relied on sending WebSocket messages from the frontend to the backend were affected by this problem.</p><p>What could be done to improve WebSocket performance? We identified <strong>three</strong> solutions:</p><ul><li>Decrease the number of WebSocket messages sent from the frontend to the backend</li><li>Scale Anycable’s servers</li><li>Make Clio’s code process WebSocket messages faster</li></ul><h3>Decreasing the number of WebSocket messages sent from the frontend to the backend</h3><p>We identified an opportunity to decrease the number of WebSocket messages sent from the frontend to the backend without affecting any user-facing features. Metrics collected by Manage showed us that about <strong>67%</strong> of WebSocket messages received by the backend were sent to a channel named Websocket Health Channel. This is a channel Clio created for the sole purpose of measuring certain WebSocket performance metrics such as time-to-subscribe and round trip time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/0*EZSTGBhoYh4NqW3x" /></figure><p>We made a simple code change to decrease the number of sessions sending messages to the Websocket Health Channel by <strong>80%</strong>. As a result, most WebSocket messages received by Manage’s backend were now focused on serving customers rather than gathering metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/0*wk2uroUhDu7RFWRj" /></figure><h3>Make Clio’s code process WebSocket messages faster</h3><p>We used DataDog’s traces feature, sorted by duration descending, to identify WebSocket messages that were frequently slow to process. One standout was the Manage::DocumentEventsChannel#request_preview action, which required four HTTP requests to a third-party service to complete, as shown in the trace below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/0*ct6hy65QHYjYJ_D8" /></figure><p>The P95 time to process this type of request was ~2.5 seconds. By moving some of the code that processes these messages from the AnyCable gRPC server into a background job we decreased the time that the Anycable gRPC server spent processing these messages by <strong>99%</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/0*p_r56RGf_3PpIa0e" /></figure><h3>Results</h3><p>After implementing these three solutions, the graph of rpc_pending_num on a typical day looks more like this. An empty graph means no backlog of WebSocket messages waiting to be processed. 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oUtim9U0Dk8H0JbO" /></figure><h3>How We Worked</h3><p>Solving the WebSocket performance issue demonstrated our commitment to our core values. We embraced a <em>Customer Success Comes First</em> mindset by prioritizing the user experience, recognizing that even a few seconds of delay could disrupt workflows. Our commitment to <em>Get</em> <em>Better Every Day</em> guided us as we used tools like Datadog to investigate, learn, and continuously refine our approach. Guided by the vision that we are a 100 year company, we didn’t just patch the problem; we engineered a scalable, lasting solution that optimizes performance across the platform.</p><p>Collaboration was key, reflecting <em>Win and Help Win</em>. We worked seamlessly, sharing insights and expertise to address the challenge holistically. Finally, this project exemplified <em>Draw the </em>Owl — taking a complex, ambiguous problem and crafting an impactful solution that ensures Clio Manage remains fast and reliable for our customers.</p><p>This effort showcases how Clio’s values guide us to innovate, collaborate, and deliver exceptional experiences for our users.</p><h3>Conclusion</h3><p>Through a combination of targeted optimizations, we significantly improved WebSocket performance in Clio Manage, enhancing both system efficiency and user experience. By reducing the load on the WebSocket Health Channel, scaling AnyCable’s server capacity, and refining our message-processing code, we effectively eliminated the backlog that caused long delays in activating user interface elements.</p><p>With these changes, WebSocket messages are now processed in near real-time, ensuring that Clio Manage remains responsive for users. This project not only resolved the immediate performance issues but also provided valuable insights for future scaling and optimization efforts. We’re excited to keep building and improving to deliver the best possible experience for our customers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4c284a79ef9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/clio-labs/improving-websocket-performance-at-clio-b4c284a79ef9">Improving WebSocket performance at Clio</a> was originally published in <a href="https://medium.com/clio-labs">Clio Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>