<?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 Julian Dobrot on Medium]]></title>
        <description><![CDATA[Stories by Julian Dobrot on Medium]]></description>
        <link>https://medium.com/@juliandobrot?source=rss-5e9eb0aee168------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*B1JdDUE2pMEsHcMF9tkCTA.jpeg</url>
            <title>Stories by Julian Dobrot on Medium</title>
            <link>https://medium.com/@juliandobrot?source=rss-5e9eb0aee168------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:45:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@juliandobrot/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[Find the top n items per group]]></title>
            <link>https://medium.com/@juliandobrot/find-the-top-n-items-per-group-348a2fea70fa?source=rss-5e9eb0aee168------2</link>
            <guid isPermaLink="false">https://medium.com/p/348a2fea70fa</guid>
            <dc:creator><![CDATA[Julian Dobrot]]></dc:creator>
            <pubDate>Tue, 06 Jul 2021 09:16:11 GMT</pubDate>
            <atom:updated>2021-07-06T09:16:11.206Z</atom:updated>
            <content:encoded><![CDATA[<p>A small database journey in the podcast jungle</p><p>In this episode of our tech posts, you learn how to solve the problem of finding a flexible number of top items based on a group. Explained in an example out of the podcast jungle with some juice and failure.</p><p>Database queries have been never my biggest strength. Then when I am able to improve something for users or can learn something I am usually very excited about it.</p><p>In this blog post, you first read about the problem I had to solve and what the value is for our clients. Secondly, I explain my approach to solve the problem and iterations and failures. Finally, I state learnings and draw some conclusions. Have fun dear reader.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SbYp2-qnZRHXIjWB48FQ8A.jpeg" /><figcaption>We aggregate audio-content at upday and serve it to multiple clients.</figcaption></figure><p>I had to improve a query that selects <strong>popular podcasts</strong> based on their subscriptions. The requirement was to <strong>normalize</strong> it over the language column and also filter out items based on some additional criteria.</p><p>You want to influence my algorithm and boost your most favorite podcast..here you go :)</p><p><a href="https://earli.audio/">Welcome to earliAudio</a></p><p>What does normalize mean in this context?</p><ul><li>Select the most subscribed n podcasts per language.</li></ul><p>The initial implementation was only selecting the most subscribed podcast across all languages, which should be improved in many directions. So let’s start.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85a468a7b56756fddec33f77923fe9a7/href">https://medium.com/media/85a468a7b56756fddec33f77923fe9a7/href</a></iframe><p>The problem with this implementation is that within different languages we have not equal user bases. This leads to overexposure in countries with a bigger user base and no or less content in others. The changes should improve this for our clients.</p><pre>+--------------------------------+--------+-------------+<br>|id                              |language|subscriptions|<br>+--------------------------------+--------+-------------+<br>|1                               |de      |7330630000   |<br>|2                               |de      |96090000     |<br>|3                               |de      |713260       |<br>|4                               |de      |675472       |<br>|5                               |de      |500895       |<br>|6                               |en      |485160       |<br>|7                               |it      |438020       |<br>|8                               |en      |424683       |<br>|9                               |de      |215798       |<br>|10                              |fr      |197039       |<br>+--------------------------------+--------+-------------+</pre><p>Sounds like an easy task and I was a bit disappointed to be not able to solve it right away 😂. The reality is I do not work on a daily basis with SQL and do not know all the features so I had to do the basic research as usual and stepped over this nice explanation for solving exactly my problem.</p><p><a href="http://www.sqlines.com/mysql/how-to/get_top_n_each_group">MySQL - How To Get Top N Rows per Each Group</a></p><p>We are using Amazon RDS (PostgreSQL) to store our data for this service. So I could utilize the ROW_NUMBER()function.</p><p><a href="https://www.postgresqltutorial.com/postgresql-row_number/">PostgreSQL ROW_NUMBER() Explained with Practical Examples</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/111365a744dc405ea65483bd80f0d5ee/href">https://medium.com/media/111365a744dc405ea65483bd80f0d5ee/href</a></iframe><pre>+--------+-------------+-------------+<br>|language|subscriptions|language_rank|<br>+--------+-------------+-------------+<br>|de      |76090        |2            |<br>|en      |48516        |1            |<br>|en      |42468        |2            |<br>|es      |29097        |1            |<br>|es      |27167        |2            |<br>|fr      |34325        |1            |<br>|fr      |25043        |2            |<br>|it      |36014        |1            |<br>|it      |33418        |2            |<br>|nl      |6378         |1            |<br>|nl      |3870         |2            |<br>|pl      |14766        |2            |<br>|pt      |5364         |1            |<br>|pt      |5109         |2            |<br>+--------+-------------+-------------+</pre><pre>Query result of initial query</pre><p>Nice! I also applied certain filters based on my product requirements and was quite happy 😃.</p><p>Last but not least write some tests to verify the functionality of the query.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41cab006debf4cf5e4df45c26b370e40/href">https://medium.com/media/41cab006debf4cf5e4df45c26b370e40/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*Ddf9_VeJoC2uj1MydxV6Nw.png" /><figcaption>😂</figcaption></figure><p>The attentive reader is probably sliding on his chair since my initial query in order to tell me what is wrong with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMpFGQOrBXP3jnfK6xFBbQ.jpeg" /></figure><p>After playing around with the limit parameter and realizing that the expected items show up when the limit was extended. I also mentioned that the first item in the query result of the initial query is missing for de as well as for pl.</p><p>This was based on the filtering of the initial query result. Moving the filters to the inner select solved this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e46607890e8f2f4b349112a920eaa004/href">https://medium.com/media/e46607890e8f2f4b349112a920eaa004/href</a></iframe><pre>+--------+-------------+-------------+<br>|language|subscriptions|language_rank|<br>+--------+-------------+-------------+<br>|de      |76090090     |1            |<br>|de      |5132600      |2            |<br>|en      |90008516     |1            |<br>|en      |7002468      |2            |<br>|es      |6090097      |1            |<br>|es      |6741067      |2            |<br>|fr      |3004325      |1            |<br>|fr      |2005043      |2            |<br>|it      |30060140     |1            |<br>|it      |3003418      |2            |<br>|nl      |1000378      |1            |<br>|nl      |1203870      |2            |<br>|pl      |9047660342   |1            |<br>|pl      |903816       |2            |<br>|pt      |50364451     |1            |<br>|pt      |501090       |2            |<br>+--------+-------------+-------------+</pre><pre>Query result of the adapted query<br>The two most subcribed podcasts per language.</pre><p>When I first discovered the bug I was about to just ship the thing because losing a few items would not have made a huge difference from a product perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_g7vpxlr117RxD-YDpFIQ.jpeg" /></figure><p>But when checking the performance of the two queries I detected a huge difference when it comes to execution time. <strong>Who</strong> saw this already when looking over the initial query? We should have a discussion 👀.</p><pre>14 rows retrieved starting from 1 in 4 s 22 ms (execution: 3 s 994 ms, fetching: 28 ms)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2HDDg3SCYrY8RfiBntOJA.png" /></figure><pre>16 rows retrieved starting from 1 in 383 ms (execution: 324 ms, fetching: 59 ms)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hZYe8GMfnzis3GNElLIcew.png" /></figure><p>The execution time of the second query is just a fraction of the first one. Reading a query plan is not so easy. Here is a good read to get a basic understanding.</p><p><a href="https://thoughtbot.com/blog/reading-an-explain-analyze-query-plan">Reading a Postgres EXPLAIN ANALYZE Query Plan</a></p><p>What are my learnings from this small task or which things are I draw lines to?</p><ul><li>I discovered one more time that the ability to pick up things and discover capabilities is more important than knowing everything, since this is not possible and things change all the time or environments differ from each other.</li><li>After working on this task and writing most of this, I asked some co-workers about their knowledge about the function and the problem and for most of them, it was also a learning.</li></ul><p>Which of our products can benefit from these changes?</p><p>We have our own microservice to serve popular-audio-content written in Kotlin like all of our applications. This service is receiving episodes from popular podcasts that are published from the component which is responsible for the importing of audio content.</p><p>You can discover popular audio-content in our mynews section in the upday application.</p><p><a href="https://www.upday.com/en/">upday upday</a></p><p>Or the earliAudio widget in Samsung Dayli.</p><p>Thanks for reading. Leave a clap or comment in case you enjoyed reading or you have any improvement suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=348a2fea70fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The snowplow-java-tracker in a multi-client service architecture]]></title>
            <link>https://medium.com/upday-devs/the-snowplow-java-tracker-in-a-multi-client-service-architecture-5febb6e590a5?source=rss-5e9eb0aee168------2</link>
            <guid isPermaLink="false">https://medium.com/p/5febb6e590a5</guid>
            <category><![CDATA[event-tracking]]></category>
            <category><![CDATA[snow-plows]]></category>
            <category><![CDATA[upday]]></category>
            <category><![CDATA[snowplow-java-tracker]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Julian Dobrot]]></dc:creator>
            <pubDate>Fri, 05 Mar 2021 15:04:57 GMT</pubDate>
            <atom:updated>2021-03-05T15:04:57.303Z</atom:updated>
            <content:encoded><![CDATA[<h4>And one library to rule them all</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJt-Otd5ZRlTvsHIHG8MQA.jpeg" /></figure><p>In this blog post, we will talk about the open-source library written in <a href="https://kotlinlang.org/">Kotlin</a> which we created in order to simplify the implementation of the <a href="https://github.com/snowplow/snowplow-java-tracker">snowplow-java-tracker</a> in our projects. Before we dive deeper into it let’s understand how Snowplow is used for events collection in our organization throughout our projects.</p><p>At upday we utilize a <a href="https://docs.snowplowanalytics.com/docs/understanding-your-pipeline/architecture-overview-aws/">Snowplow pipeline</a> approach to tracking user-events and store them in our Data Warehouse. We track events in web-based, native frontend, and backend applications. This is visualized in the below diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*ihgGCxE2DNkZh7_X-oZH6A.png" /><figcaption>Snowplow Pipeline</figcaption></figure><h3>The problem and our solution</h3><p>We use the snowplow-java-tracker in multiple microservices. In order to do so, we had to implement the tracker component and its configuration as well as the emitter again in each of the services.</p><p>Also, any bug or change in the tracker or emitter needed a patch in all the services that use the <a href="https://github.com/snowplow/snowplow-java-tracker">snowplow-java-tracker</a>. Additionally, to make our system more robust we had to attempt retrials for failed events in case of downtime of the event collector endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*PUkrVDx-XqHrHr-rlAt2wA.png" /><figcaption>Visualization of different services with the use case of sending events</figcaption></figure><p>We abstracted the tracker and emitter creation to a separate library <a href="https://github.com/upday/snowplow-java-tracker-wrapper">snowplow-java-tracker-wrapper</a> with default tracker and emitter properties. This library can now be added as a dependency in our services which implements the snowplow-java-tracker. We also enhanced our library to take care of failed event retrials in case the snowplow collector URL is down with up to five exponentially backed-off retrials by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*ZeR0IHI1NlGwgGmUvJKAJw.png" /><figcaption>Main components of the wrapper library</figcaption></figure><h3><strong>How to use the Library</strong></h3><p>In order to get started, add the <a href="https://jitpack.io/#upday/snowplow-java-tracker-wrapper/0.0.9">JitPack</a> repository together with the snowplow-java-tracker-wrapper dependency to your project. There you can find the latest released version of the library.</p><p>To start sending your events, you need to instantiate the SnowplowDispatcher class with your application properties. This takes care of creating the tracker and the emitter. After that, you need to call the send method that submits your events to the collectorUrl.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0e0d0764e58106c1e80be23f66b6330/href">https://medium.com/media/f0e0d0764e58106c1e80be23f66b6330/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18e0892dc149abf26581780d744b9c47/href">https://medium.com/media/18e0892dc149abf26581780d744b9c47/href</a></iframe><h3>But what about the performance?</h3><p>We have been using this library to collect events in our production environment for the last four months.<br>So far the performance has been stable where we have a traffic of about 100 requests/sec, generating snowplow events at a similar rate. Here is a performance report of one of our services using this library to send events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*niYB4kVR_39pzcO9zrf_4g.png" /></figure><p>However, we recommend you to run a load test based on your expected traffic before using this library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tz3S3jse7_0CJFb-siMaaw.png" /><figcaption>Received events in the Snowplow collector</figcaption></figure><h3>Happy event sending :)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9MnHDfcH9vMWPYrr67Ebpw.jpeg" /></figure><p>We hope you enjoyed reading our blog post and we would be happy if someone utilizes or even improves the library. Please feel free to contribute to our open-source library <a href="https://github.com/upday/snowplow-java-tracker-wrapper"><strong>snowplow-java-tracker-wrapper</strong></a>. We thank all our contributors so far.</p><p>Cheers, <a href="https://medium.com/u/d2cb2a63a561">Monika Singh</a> and <a href="https://medium.com/u/5e9eb0aee168">Julian Dobrot</a> :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5febb6e590a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/upday-devs/the-snowplow-java-tracker-in-a-multi-client-service-architecture-5febb6e590a5">The snowplow-java-tracker in a multi-client service architecture</a> was originally published in <a href="https://medium.com/upday-devs">upday devs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>