<?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 Mikhail Beschastnov on Medium]]></title>
        <description><![CDATA[Stories by Mikhail Beschastnov on Medium]]></description>
        <link>https://medium.com/@mbeschastnov?source=rss-5b957c96e485------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OkB1yCc4OVppnd8VjnowIg.jpeg</url>
            <title>Stories by Mikhail Beschastnov on Medium</title>
            <link>https://medium.com/@mbeschastnov?source=rss-5b957c96e485------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:25:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mbeschastnov/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[WebSocket vs. HTTP for collecting events for Web Analytics]]></title>
            <link>https://medium.com/nativeai/websocket-vs-http-for-collecting-events-for-web-analytics-c45507bd7949?source=rss-5b957c96e485------2</link>
            <guid isPermaLink="false">https://medium.com/p/c45507bd7949</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[digital-publishing]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[web-analytics]]></category>
            <dc:creator><![CDATA[Mikhail Beschastnov]]></dc:creator>
            <pubDate>Thu, 30 Aug 2018 19:50:41 GMT</pubDate>
            <atom:updated>2018-08-30T19:50:41.680Z</atom:updated>
            <content:encoded><![CDATA[<p>Analytics tools are a vital cog of every industry these days, and in digital news publishing, <a href="https://www.native.ai/analytics">analytics tools</a> are critical because the primary product is published content and analytics reports are essentially the diagnostics of the business.</p><p><strong>Establishing Requirements</strong></p><p>Given the high frequency of publication, rapidly developing news-scape and unpredictable surges and dips in reader interest, real-time analytics reports become a necessity in publisher analytics tools. The availability of real-time content usage and audience engagement statistics can be valuable for decision making in newsrooms, editorial meetings and audience development stand-ups. As a consequence, several publisher-focused analytics platforms in the market offer real-time analytics metrics and reports.</p><p>When you choose an analytics platform, your main considerations should be:</p><ul><li>What data analysis capabilities does the platform provide?</li><li>How reliable is the collected data?</li><li>What is the impact on the performance of your application/website from using the analytics library?</li></ul><p>In this article, I will concentrate on the last 2 points, because they are platform-agnostic and can be compared across all options, and I will also tell you how we at NativeAI deliver on these two fronts, to achieve high data reliability with minimum a footprint on website / application load-times.</p><p><strong>HTTP-based Messaging — the good and the bad</strong></p><p>Analytics tools rely on being able to collect data on user acquisition &amp; behavior in the mobile app or browser and sending it to the servers of the Analytics platform for processing. These events typically include attributes such as referrer, URL, location and interaction events such as clicks, impressions, scroll etc. There are also derived metrics such as time spent, bounce rate etc. which rely on other events such as tab close. HTTP based messaging offers a proven messaging channel to the analytics server, but has its shortcomings.</p><p>If we assume that all analytics client-side libraries are written to be equally efficient at processing, then the overall performance footprint and data reliability depends on client-server communication efficiency. The most commonly used approach to client-server communication, used by many popular analytics platforms like <a href="https://www.native.ai/blog/google-analytics-vs-custom-analytics-for-publishers">Google Analytics</a> or Flurry Analytics, is HTTP-based messaging using techniques such as XHR, pixel tracking, or JSONP.</p><p>Unfortunately, these techniques have several down-sides, especially when it comes to web browser clients:</p><ol><li><strong>Not really real-time + data loss risk</strong>: HTTP requests always have a delay that is caused by browser defer, http connection opens etc. This delay could have a huge impact on reliable collection of analytics data, especially for “tab closed” or “navigate away” events — in many cases HTTP simply can’t initialize the request in time and loses the event.</li><li><strong>Slow page load speeds</strong>: Every Web browser has a limited “resource” pool for all HTTP-based requests including HTML, CSS, fonts, javascript libraries, images and other media as well as XHR and JSONP. This pool is organized by resource priority where the priority of XHR or JSONP requests is the least, and the pool has limits on the number of parallel network requests. This means that excessive usage of third-party HTTP-based libraries including analytics libraries may slow down your website significantly because these libraries could flood the pool with a lot of requests. On the other hand, low priority HTTP requests may wait in the pool for long time (up to a few minutes), which results in losing user sessions and events for those who browse the website for only a short time eg. readers who read only 1 article in a session.</li><li><strong>Increased bandwidth / data consumption</strong>: HTTP communication has huge data transfer overhead sending protocol-related information like headers with every request/response.</li></ol><p><strong>How we do this on NativeAI Analytics</strong></p><p>When we were just <a href="https://medium.com/nativeai/why-an-analytics-tool-which-understands-content-makes-a-difference-e7d6102000e1">getting started with NativeAI</a>, we opted to use HTTP-based communication, but we faced all the above issues as we expanded the range of events we record and increased the number of clients we serviced. To tackle this, in March 2017, we switched to a completely different communication protocol — WebSocket.</p><p>WebSocket helped us address all the above mentioned problems:</p><ol><li>Since websocket connection is always open and ready to receive messages, user event can be reliably sent to server even when browser tab is closed unexpectedly or if a user navigates away from the website. It is also much more closer to real-time because it does not involve elaborate network initiation before event data can be transferred, every time.</li><li>The image below illustrates a comparison in communication time between WebSocket and REST HTTP for fixed message rate and fixed message size, in one of our tests:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bJD5qwpuG0S8J1E7" /><figcaption>Event upload time : Websocket vs. REST for Analytics Tools</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ijpuiKrJKnZfbnq0" /><figcaption>Number of messages: Websocket vs. REST for Analytics Tools</figcaption></figure><p>3. A WebSocket connection is not affected by browser resource pool limitation, and does not impact the load-times of other website resources, which makes it an ideal protocol for a third-party library that intensively communicates with server.</p><p>4. WebSocket is much more traffic-efficient than HTTP, because, once the connection is established, WebSocket will only send plain messages without any additional protocol-related information.</p><p><strong>Impact of the move to WebSocket</strong></p><p>On Reliability:</p><p>As a result of switching to WebSocket, we increased reliability of event delivery by ~20% across multiple rounds of tests. NativeAI is able to capture almost every single user interaction, including edge cases such as rapid window closure, intermittent networks etc. This translated to a richer data store of interaction events, higher accuracy of recording and more happy customers for NativeAI.</p><p>On Performance:</p><p>To illustrate the impact on performance, the image below shows the waterfall chart of a browser loading resources. Here you can see that resources are loaded in parallel, and the number of parallel requests is limited, that’s why the loading sequence looks like waterfall. Also, there are resource priorities that depend on resource type and amount of data transferred in response. As you can see, the Websocket request doesn’t have any priority and doesn’t have a response size, because it’s not considered in the resource pool. It is shown as a stalled request here because it doesn’t use an active HTTP connection, rather it keeps WebSocket connection opened and ready to accept messages. All there factors make WebSocket communication highly efficient for the use case of an Analytics tool which can deliver reliable real-time data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/0*UBuTmJDRtWxCpVb4" /><figcaption>Chrome waterfall chart for HTTP requests</figcaption></figure><p>We dramatically reduced or even eliminated website latency / load-speed performance issues arising from the use of the Analytics script on our publishers’ websites. This is a very critical concern faced by most large publishers, as search engines and social media platforms place a premium on user experience on websites as a function of load speeds.</p><p>In summary, we can assert with confidence that choosing WebSocket has given <a href="https://www.native.ai/analytics">NativeAI Publisher Analytics</a> a significant edge in reliability, accuracy and performance as compared to other analytics tools in the market.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c45507bd7949" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nativeai/websocket-vs-http-for-collecting-events-for-web-analytics-c45507bd7949">WebSocket vs. HTTP for collecting events for Web Analytics</a> was originally published in <a href="https://medium.com/nativeai">NativeAI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>