<?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[AntVoice Tech - Medium]]></title>
        <description><![CDATA[AntVoice helps brands and merchants to identify and target new clients through weak signals analysis and artificial intelligence. - Medium]]></description>
        <link>https://medium.com/antvoice-tech?source=rss----b6cfc462c219---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>AntVoice Tech - Medium</title>
            <link>https://medium.com/antvoice-tech?source=rss----b6cfc462c219---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 12:42:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/antvoice-tech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How we are streaming thousands of rows per second into BigQuery — Part II: Google Storage loading]]></title>
            <link>https://medium.com/antvoice-tech/how-we-are-streaming-thousands-of-rows-per-second-into-bigquery-part-ii-google-storage-loading-3e1236d8872f?source=rss----b6cfc462c219---4</link>
            <guid isPermaLink="false">https://medium.com/p/3e1236d8872f</guid>
            <category><![CDATA[google-cloud-storage]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Bastien Moyet]]></dc:creator>
            <pubDate>Thu, 17 Feb 2022 10:00:20 GMT</pubDate>
            <atom:updated>2022-02-17T10:00:20.399Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we are streaming thousands of rows per second into BigQuery — Part II: Google Storage loading</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zFN86bgyCzSJaaxV" /><figcaption>Photo by <a href="https://unsplash.com/@kimileee?utm_source=medium&amp;utm_medium=referral">Kimi lee</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://medium.com/antvoice-tech/how-we-are-streaming-thousands-of-rows-per-second-into-bigquery-part-i-google-cloud-dataflow-9465fdcd436d">the previous post</a>, we described how we are leveraging Google Cloud Dataflow to record our data in BigQuery. Though it has some great advantages, it began to become more and more expensive.</p><p>So we had to figure a way to reduce these infrastructure costs.</p><h3>The cost items</h3><p>The cost came from 3 Google Cloud components:</p><ol><li><a href="https://cloud.google.com/pubsub/pricing#pubsub">The PubSub throughput</a></li><li><a href="https://cloud.google.com/compute/vm-instance-pricing">The Dataflow VMs</a></li><li><a href="https://cloud.google.com/bigquery/pricing#data_ingestion_pricing">The BQ streaming insert</a></li></ol><h3>The basic idea</h3><p>We quickly looked into the possibility to load data into BigQuery from Google Cloud Storage files (abbreviated GCS from now on). It is the only other way to load data into BQ if we want to avoid streaming costs.</p><p>We found that Dataflow has an option to not stream inserts into BQ, but rather load them using batch loading. But using this solution did not address our 2 main items. So we had to figure a way to also reduce those costs.</p><p>So we searched for a way to write our data quickly enough into GCS to meet our main demands :</p><ol><li>Don’t impact our running services</li><li>Don’t rely on a message bus system requiring to scale up when the demands grow and which was expensive</li><li>Write data quickly enough for the data to be readable on our reporting UI. We need the data to be loaded as often as 15 minutes to have the freshest data possible.</li></ol><h3>How we did it</h3><p>To find our solution, we began from the end of the workflow. Indeed we knew we had to use the file batch loading into BQ from GCS.</p><p>Then we had to find a way to write JSON into GCS without impacting our services. Since we were using Kubernetes, we knew that we could attach sidecars to our running pods. And these sidecars could share the same volumes as our services.</p><p>So we simply tried to write JSON lines into files directly in the pods file system and made a sidecar to transfer these files to GCS. Then the last step was to simply create a cron to load these files periodically.</p><p>That’s when our solution called GCS Streaming was born. The final architecture now looks like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*s9A0uN_83fMqiad9XIi4Kg.png" /></figure><p>When we developed the GCS Streamer we already had some jobs running in Go. So we naturally went for it.</p><p>The code is pretty simple:</p><ol><li>Listen to directory modification events (file created, file moved) using the library <a href="https://github.com/fsnotify/fsnotify">FsNotify</a>.</li><li>Transfer those files to GCS</li></ol><p>It looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50b078a151b558de0bb52cf825b6906c/href">https://medium.com/media/50b078a151b558de0bb52cf825b6906c/href</a></iframe><h3>Impacts</h3><p><strong>The cost reduction was between 5 to 10 times</strong> versus the dataflow costs depending on the data throughput. We are currently using a mix of both solutions where the voluminous data is going through this new solution, and where critical data still go through the old one.</p><p>We stuck with the old one for critical data for 2 reasons:</p><ol><li>The data is <strong>streaming nearly instantly into BQ</strong> which allow us to use it in monitoring and reporting tools. And some services also need the data to be available as soon as possible</li><li>The dataflow solution is lossless, whereas going through file system streaming and copying locally and then on GCS <strong>is causing a minimal loss</strong> (mainly due to pod restarts). But this loss, which is constantly monitored, was acceptable regarding the reduced cost and the data criticality. Nowadays we may be losing less than 0.01%.</li></ol><p>We were also using the Dataflow streaming in our QA context until recently because e2e tests needed the data to be loaded as quickly as possible. However, we recently switched to the batch loading version as our preproduction environment are now able to load GCS file on the go, which is as fast as the streaming version. It even fixed some issues where data was stuck in the BQ streaming buffer.</p><h3>Conclusion</h3><p>Using this new way of inserting data in BQ is saving us a lot of money. It allowed us to scale up peacefully, and to accept much more incoming load without seeing our bills skyrocket.</p><p>We chose this architecture because we could allow medium latency insertions. And it allows us to scale up without a linear cost hike.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e1236d8872f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/antvoice-tech/how-we-are-streaming-thousands-of-rows-per-second-into-bigquery-part-ii-google-storage-loading-3e1236d8872f">How we are streaming thousands of rows per second into BigQuery — Part II: Google Storage loading</a> was originally published in <a href="https://medium.com/antvoice-tech">AntVoice Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT history matters]]></title>
            <link>https://medium.com/antvoice-tech/git-history-matters-2b85317c8d?source=rss----b6cfc462c219---4</link>
            <guid isPermaLink="false">https://medium.com/p/2b85317c8d</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[good-practices]]></category>
            <dc:creator><![CDATA[Slim Ayache]]></dc:creator>
            <pubDate>Thu, 13 Jan 2022 14:49:15 GMT</pubDate>
            <atom:updated>2022-01-14T09:40:22.438Z</atom:updated>
            <content:encoded><![CDATA[<h3>GIT History Matters ✌</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*UBfIl9LPclrCJI8ecECRlQ.jpeg" /></figure><p>Having a nice, clean git history is important for many reasons :</p><ul><li>Help understand how a developer proceded to implement a solution and help in <strong>code reviews</strong></li><li>Leave clean traces about <strong>code snippets</strong> and implementations that can be used as examples or starting points in the future</li><li>Helping in <a href="https://git-scm.com/docs/git-cherry-pick"><strong>cherry-picks</strong></a>, <strong>rollbacks </strong>and every thing related to versionning</li><li>Understand the <strong>evolution</strong> of the code</li><li>Quickly detect <strong>regressions </strong>by making simple compares</li></ul><p>To do so we should be more careful about the way we archive our code.</p><h3>Commit Frequency ⏰ :</h3><p>It’s up to every developer to judge how often he should commit, but it’s a good practice to try to commit as soon as a unit of work is done.</p><h3>Commit or Stash 🤔 ?</h3><p>We should not commit unfinished or bad code when trying to test a different solution or when changing to a different branch.<br>Rather than committing things like “<em>To be Done later</em>” , “<em>Work in progress</em>” .. and so on, we should use stashing.</p><p><a href="https://git-scm.com/docs/git-stash">https://git-scm.com/docs/git-stash</a></p><h3>Commit content 📖 :</h3><p>Avoid committing too many things at the same time. Try to commit “units” of coherent code.<br>Commits should be as isolated as it can be.</p><p>Examples of “<em>unit of work</em>” :</p><ul><li>Refactoring</li><li>Adding/modifying a service</li><li>Fixing things</li><li>Adding scripts</li><li>Renaming / moving files</li></ul><p>When you need to select some lines from a file a leave others use interactice staging : <a href="https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging">https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging</a> . This way you may be precise of what to put in your current commit and what to leave for the next ones.</p><h3>Amend and Squash 🔧 ?</h3><p>When you need to add some content to your last commit use Amend rather than making a new commit. You may need to <a href="https://git-scm.com/docs/git-push#Documentation/git-push.txt---force">force push</a> for that purpose.</p><p><a href="https://git-scm.com/docs/git-commit#_options">https://git-scm.com/docs/git-commit#_options</a> - (search amend)</p><p>You can useSquashto simplify your commits or to regroup two commits that are strongly tied to eachother. This action can be done at the end of your developements and before the code review.</p><p><a href="https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History">https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History</a> (search squash)</p><h3>Commit messages 📝 :</h3><p>The commit message should have a structure that answers these three questions :</p><ul><li><em>What does this commit do ? </em><strong><em>[mandatory]</em></strong><br>=&gt; a general description (with verb in present tense)</li><li><em>What are the details of this commit ?</em> <strong><em>[optionnal]</em></strong><br>=&gt; Details (with verbs in past tense)</li><li><em>For what task ? </em><strong><em>[highly recommended]</em></strong><em> </em><br>=&gt; The related user story (using # in the beginning or in the end)</li></ul><p>A good practise is to include the backlog work item id with a hashtag # at the beginning or the end of the commit (personnaly I like to prefix with it)</p><p><strong>Example :</strong></p><blockquote><em>Persist </em><em>Foo in </em><em>Stuff<br>- Added logs<br>- Modified XXXX<br>- fixed unit test YYYY<br>#11223</em></blockquote><p>The details section of a commit is not mandatory, while the description and the tasks should be.</p><p>Avoid commits like :</p><ul><li>Fix Bug</li><li>Test 2</li><li>Screw this ****</li><li>bla bla bla</li></ul><h3><strong>Make it searchable </strong>🔍 :</h3><p>Keep in mind that you may want to look for your commits in some time for whatever reason, so keep it “searchable”. By this we mean that some other developer may want to Search for a specific commit from time to time with some key words. Please , help this guy (It might even be the future you! ).</p><p><strong>Example</strong> :</p><p><em>“Fix timeout issue by introducing a retry mechanism”</em></p><p>Is better than :</p><p><em>“Fix timeout issue”</em></p><p>As we can search in the future for this “retry mechanism” to use it or generalize it.</p><h3>Master &amp; Hotfix — commits 🚒 :</h3><p>When there is no task id to link, we should add a suffix to our commits</p><ul><li>For hotfixes we can add “<strong>SUPPORT _ </strong>commit text”</li><li>The other cases are to be defined.</li></ul><h3><strong>Tag while you can </strong>📌 <strong>:</strong></h3><p>Tags are very useful for post production follow up. Tag your commits while you can with meaningful versions / text.</p><h3>Some might say 😏 :</h3><h4>Hey I never looked to git history before, why should I care ?</h4><p>Well, you should start to care, because it’s important to know what happened in order to handle what’s next. Git history, if done right, can save you from a lot of trouble and complete your understanding of the solution, especially when nobody is there to tell you the story.</p><h4>Hey, commits are my private things ! Since I’m going to use a squash-merge to master afterwards</h4><p>Yes, commits can be a “private matter”, but code reviews are not. And since commit messages come with the code reviews, they should be taken into consideration as for the rest. If you’re working in your own repository, then do whatever suits you. But when you work in a public/shared one, you should try your best to bring the clearest code and documentation, thus git history, to your colleagues.</p><h3>What other people said about git history 📜 :</h3><p><a href="https://gist.github.com/turbo/efb8d57c145e00dc38907f9526b60f17">https://gist.github.com/turbo/efb8d57c145e00dc38907f9526b60f17</a></p><h3>Git Cheat sheet &amp; Graphical tools 💻 :</h3><p>For those fond of shell and black screens :</p><ul><li><a href="https://education.github.com/git-cheat-sheet-education.pdf">GitHub cheat sheet</a></li></ul><p>For those who want to chill :</p><ul><li><a href="https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Graphical_Interfaces">Git Graphical Interfaces</a></li></ul><p>Respectful IDE like Rider and Visual Studio are also providing some great integrated tools (you can even create your <a href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests">pull request</a> from them, or even pick only some line to commit in a changed file) :</p><ul><li><a href="https://www.jetbrains.com/fr-fr/rider/features/#version-control">Rider Git UI</a></li><li><a href="https://docs.microsoft.com/en-us/visualstudio/version-control/?view=vs-2022">Visual Studio</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b85317c8d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/antvoice-tech/git-history-matters-2b85317c8d">GIT history matters</a> was originally published in <a href="https://medium.com/antvoice-tech">AntVoice Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we built our tech stack at AntVoice]]></title>
            <link>https://medium.com/antvoice-tech/how-we-built-our-tech-stack-at-antvoice-ebbe2b20661b?source=rss----b6cfc462c219---4</link>
            <guid isPermaLink="false">https://medium.com/p/ebbe2b20661b</guid>
            <category><![CDATA[tech-stack]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[adtech]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Slim Ayache]]></dc:creator>
            <pubDate>Tue, 09 Nov 2021 09:58:07 GMT</pubDate>
            <atom:updated>2021-11-09T09:58:07.251Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we’ll be talking a little bit about AntVoice as a tech startup and then, about the tech stack we’re using (and why).</p><h3>A Quick tour of the house</h3><h4><strong>In a nutshell :</strong></h4><p><a href="https://www.antvoice.com/en/"><em>AntVoice</em></a> is an <a href="https://www.techopedia.com/definition/31293/ad-tech">AdTech</a> company that offers a predictive-targeting solution and in banner personalized recommendations, all of this is backed by machine learning algos.</p><p>This basically means three things in a purely technical perspective :</p><ul><li>💹 Real-time bidding</li><li>📊 (Big) Data Centricity</li><li>⚡ High performance and Scalability (up &amp; down)</li></ul><h4><strong>More in details :</strong></h4><p>As of today, our platform is handling on average some <strong>15k requests per second</strong>, with a response time threshold of <strong>50 milliseconds</strong>. <br>Yes, I know, it is (very) fast, indeed, and we’re proud of it !</p><p>We’re actually proud because during these <strong>50ms</strong> we process a <strong>real time</strong> <strong><em>prediction</em></strong> and <strong><em>pricing</em></strong> <strong><em>computations</em></strong> based on all the data we gathered on a specific user and the Ad location. This involves multiple model evaluations. All of this is much more evolved than responding to requests with a basic algorithm.</p><h4><strong>Behind the scenes :</strong></h4><p>A <a href="https://www.monetizemore.com/blog/what-is-a-bid-request/">bidding decision</a> has to be taken <strong>automatically</strong> and <strong>accurately</strong> in order to buy an advertisement space at the <strong>best price</strong> for the <strong>right audience</strong> and track the results of this bidding, whether it is won or not, to feedback our recommendation and pricing [AI] algos.<br>That generates a bunch of data that is stored, processed and used everywhere.<br>This also implies that we need an <strong>elastic infrastructure</strong> able to adapt to the high and low picks of every minute of a day so that we don’t miss an opportunity when minimizing technical costs.</p><p>👀 Well that is a lot of things ! but rest assured that we’ll come back with other articles in the future to talk about this stuff in depth.</p><h4><strong>(Do the) Evolution :</strong></h4><p>AntVoice stack has evolved over the years in accordance to every change in its business model. What started as a <em>product recommendation service</em> is now a whole DSP (<a href="https://en.wikipedia.org/wiki/Demand-side_platform"><strong>Demand Side Platform</strong></a>) solution offering clients a way to acquire new audiences thanks to predictive-targeting ads.</p><p>Many smart people (former and current developers; my wonderful colleagues 💖) contributed to build the ecosystem. Every-one brought a neat value to the project. <br>Despite the tech team size that has always been around a single <a href="https://whatis.techtarget.com/definition/two-pizza-rule"><strong>two-pizza team</strong></a> , AntVoice’s tech stack has always been rich, thoughtful, and above all : alive ! - it continues to change.</p><h3>Our tech stack</h3><p>AntVoice’s tech stack evolved a lot during the last five years. We love to challenge it and test new technologies we could use to improve our platform. Here is our stack current snapshot, but be sure it will continue to change in the next few months.</p><p>We won’t go through deep explanations about all the choices we made as these will be developed in future articles.</p><p><strong>NOTE</strong> : every mention of “<em>on-premises</em>” does mean a service is hosted or installed in one of our virtual machines (not a local one) — as opposed to any cloud service in “<em>SaaS”</em> mode.</p><h3>Languages :</h3><p><em>Programming languages. Some we “speak” fluently, and some we use less.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*47XPvl4pXRAyn0muFkJiTw.png" /></figure><ul><li><strong>C# </strong><br>We happily use the latest version of it. It’s a very powerful general-purpose, multi-paradigm, and in my case, enjoyable to use language. It represents roughly <strong>70%</strong> of our backend of our code base and has been there since the beginning.</li><li><strong>F# </strong><br>Introduced to improve modeling, and take advantage of functional programming.<br>We like it so much that our newest web APIs have been created with F#. <br>We could mix both of the .net languages in many parts of our code without having to rewrite / translate any code and it worked out pretty well. It represents some <strong>25%</strong> of our backend code base.</li><li><strong>Rust</strong> <br>The latest adopted language, needed for high performance.<br>As we reached some of the limits of vertical scaling with C# and F#, we looked for a more performance oriented language. After some POCs Rust won our confidence and interest, but not without many struggles to understand its philosophy and make it work. It represents about <strong>5%</strong> of our backend code base.</li><li><strong>TypeScript</strong> <br>The strongly typed and refactoring friendly web language. <br>We used it to create our tag library and we use it for every new frontend dev.</li><li><strong>JavaScript</strong> <br>We’re talking here about plain old vanilla JS. It tends to disappear in front of TS. We can consider it as a legacy language in our stack.</li><li><strong>Python</strong> <br>DataScientist’s best friend. Used also for some tooling tasks by developers.</li><li><strong>Scala/Spark</strong> <br>Used by data science, when running spark clusters.</li><li><strong>Go</strong> <br>Used in some prototypes but Rust was more adapted to our needs. In maintenance only.</li><li><strong>Java</strong> <br>As a marginal usage, we have some lines of Java used by necessity in a dataflow job.</li></ul><h3>Local development environment :</h3><p><em>Tools we use to make work done</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*oC29DH7Vxdr0MSwqPfUUuQ.png" /></figure><ul><li><strong>Ubuntu</strong> ~ focal fossa <br>We wanted to have the closest environment to the prod. Thus, we are 100% on Linux. Ubuntu is a user-friendly distribution with lots of support, the choice was easy to make.</li><li><strong>Visual Studio Code</strong> <br>The most beloved editor ever (a totally unbiased description, haha)</li><li><strong>Rider</strong> <br>Super powerful, full of great features, and works great in linux</li><li><strong>IntelliJ</strong><br>We use it especially for rust development but also for Scala/Spark too.</li><li><strong>Jupiter Notebook<br></strong>Used by our data scientist for model prototyping and statistical analysis.</li><li><strong>Robot3T</strong><br>“Who needs a graphical client ?” — said my team mate; well, for lazy bastards like me here’s a simple mongoDB graphical client</li><li><strong>Postman</strong><br>We are satisfied with the free version for each developer;</li><li><strong>Terminal</strong><br>Linux best friend</li></ul><h3>Dev Stack</h3><p><em>What developers use to build our sweet platfom.</em></p><h4><strong>Frameworks</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*BoDtBmlSbFNQSbpL3eeA6g.png" /></figure><ul><li><strong>.Net 5<br></strong>We try to always be up-to-date with the latest improvements and .Net (core) frameworks as we’re using two of its languages. <br>And also because we’re full linux (dev &amp; production), we always look for the most stable framework, and in this matter .Net 5 works like a charm.</li><li><strong>Angular</strong><br>We started using angular since the first versions. It works well, and we stick with it because it meets our (few) UI needs.</li><li><strong>Asp.net core</strong> <br>Our framework for c# web APIs. Does it need an intro ?</li><li><strong>Giraffe</strong><br>Our framework for F# web APIs, knowing that we tend to favor F# for our new services.</li><li><strong>REST</strong><br>Even if this is neither an architecture nor a framework, I included it here as a ‘bag’ for all RESTful frameworks and libraries we’re using (as we also use Grpc)</li><li><strong>Grpc</strong><br>When it comes to performance, this google framework for remote procedure calls over http is a champion. Used for our low latency bidding services.</li></ul><h4>Logging</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*SLnXI3esEz3hpqZN-arlCQ.png" /></figure><ul><li><strong>ElasticSearch / Kibana</strong> <br>A standard in the logging world. We do not use logStash though. We’re happy with the on-premise service.</li><li><strong>FluentD<br></strong>Rather than manually building a specific logging layer for each of our hetegeronous projects we relied on the <a href="https://www.fluentd.org/">fluentD</a> for the task of collecting and recording logs in a unified fashion.</li></ul><h4>Data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*dsoGwIzkJtdGjg9nF3cY0g.png" /></figure><ul><li><strong>Mongo</strong><br>We only use <strong>no-sql</strong> data and MongoDb is the document-oriented database we chose. Mongo is well documented and accessible, but we tend to challenge it from time to time. We have a primary (master) server and a secondary (slave) one to handle failures. The data-duplication happens very often during the day.</li><li><strong>Redis</strong><br>We needed a simple and effective key-value / cache database, and Redis responded to these needs. We used it also for some pub/sub mechanism when dealing with configuration refresh for instance. But the more we look for performance, the more we go for AeroSpike.</li><li><strong>AeroSpike</strong><br>For everything related to caching and key-value storage, aerospike is a performance monster. We use it in-memory for super fast caching (for our bidding engine for instance , and with persistence for recommendation pre-calculations.</li><li><strong>BigQuery<br></strong>It’s a Serverless, highly scalable, and cost-effective multicloud data warehouse designed for business agility (<a href="https://cloud.google.com/bigquery">described here</a>). <br>The most important thing for us with bigQuery is to stream Tb of data without having to manage it. The Access time for data usage is pretty good. It’s also super easy to query thanks to an (almost) <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax">standard SQL query syntax</a>. <br>All these advantages come with a cost (a money one) — a cost for storage, and a cost for usage. Thus, we have to be careful with our queries and partition keys.</li></ul><h3>Infrastructure</h3><p><em>What we use as our global infrastructure.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*MAIIIaFv1renkTaN5xmtqA.png" /></figure><p>We use a <strong>microservices</strong> architecture with services that communicate synchronously using <strong>REST</strong> and <strong>Grpc</strong>, and asynchronous thanks to <strong>messaging queues (pub/sub)</strong>. We also use <strong>cron jobs</strong> and background tasks. We decided to go <strong>full Cloud</strong> for all the benefits cloud computing could bring.</p><h4><strong>GCloud</strong></h4><p>All is deployed on google public cloud. The choice was based on the pricing compared to AWS and Azure, but also on the Big Data and AI services offered by GCLoud. This is a non exhaustive list of the services we use the most :</p><ul><li><em>BigQuery</em></li><li><em>Compute engine</em></li><li><em>DataProc</em></li><li><em>Kubernetes engine</em></li><li><em>Pub/Sub</em></li><li><em>DataFlow</em></li><li><em>CDN</em></li><li><em>Storage</em></li></ul><h4><strong>Terraform</strong></h4><p>is our <strong>infra-as-code</strong> description language.With it we can create any google cloud resources we need, and keep track of every change in Git history.</p><h4><strong>Istio</strong></h4><p>It’s the service mesh we are using, to handle our microservices communications and traffic</p><h4><strong>Ansible</strong></h4><p>Ansible is the tool we are using to set up our managed VM (aerospike/mongo server for example). It creates disks, users, services, etc.</p><h3>DevOps stack</h3><p><em>What we use as a devOps to build, deploy and monitor.</em></p><h4><strong>Code</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Iw0SZeqyyPLvx17X1IGgBw.png" /></figure><ul><li><strong>Azure devops<br></strong>The good thing is our plan is free thanks to our team size, and we like it.<br>We’ve been constantly customizing it to meet our needs.</li><li><strong>Git</strong><br>I think it’s the obvious choice for every code base nowadays.<br>Our repositories are in azure devops except one open source library we hosted in GitHub.</li><li><strong>Mono-repository<br></strong>This is neither a technology nor an architecture, it’s the choice to put all the code in one place, i.e to use a single technical solution / code repository for all the services rather than separate ones. This choice has advantages and drawbacks :<br>- The <strong>con</strong> is that we have to make a custom build and deploy process that selects what has changed (and we did it), and be careful of the bigger impacts of shared libraries changes.<br>- The <strong>pro</strong> is avoiding nuget hell and similar issues, but also making refactoring and developing way faster.</li></ul><h4><strong>Build</strong></h4><ul><li><strong>MakeFile<br></strong>since the days of C programming this tool has never ceased to be used. We use it for all kinds of things, from build scripts to publish ones, to simple automation and ‘shortcut’ tools.</li><li><strong>Fake<br></strong><a href="https://fake.build/">it’s MakeFile, made functional with F#</a> . We have a custom library, built with Fake, used to detect the changes in our monorepo and deploy the adequate jobs and services. <br>Hopefully, We’ll detail this part soon enough in a future article.</li></ul><h4><strong>Deployment</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rVMt6s-cJ-gCDl_9u5WyVQ.png" /></figure><ul><li><strong>Teamcity</strong> <br>We’ve just migrated to the 2020 version , on-premises.</li><li><strong>Docker</strong><br>the super-star container</li><li><strong>Kubernetes<br></strong>As we have a real need of horizontally scaling up and down we adopted kubernetes for all our deployments.</li><li><strong>Helm<br></strong>We used HELM as a higher-level kubernetes tool. Thanks to its Charts we created a few unified deployment templates where we inject variables per environment, to quickly create or update our services.</li><li><strong>Apache Airflow<br></strong>This tool is used especially by our data scientist to schedule and monitor the many workflows and computations we need to run every week for our pricing and recommendation engines.</li></ul><h4><strong>Monitoring</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*96FK2lc1gsgr1ouYW0aRmQ.png" /></figure><ul><li><strong>Kibana</strong><br>We use some dashboards and follow log evolution with every deployment</li><li><strong>Prometheus</strong><br>Prometheus collects metrics by scrapping http endpoints in our applications. Some of these metrics are essential, even vital, to our business — for instance we have to monitor our spending trends for our bidding service, or banner click rates for our billing service.</li><li><strong>Grafana</strong><br>Awesome analytics visualization service that we use on-premises.</li></ul><h3>QA Stack</h3><p><em>What we use on a daily basis to test and write automation tests</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*zS062hNm2V6QkCFt0f9kfQ.png" /></figure><h4><strong>Unit testing</strong></h4><p>XUnit, Moq, Foq, AutoFixture and many other testings units testing libraries</p><h4><strong>Functional testing</strong></h4><p>Our browser tests are enclosed in containers. We use <strong>Selenium</strong> to orchestrate all our test suit along with <strong>docker-compose</strong>.</p><h3>DataScience Stack</h3><p><em>What our Data Science magicians use</em></p><p>As mentionned earlier, <strong>Python</strong>, <strong>Jupyter</strong> and <strong>AirFlow</strong> are the mains tools used for our data chef. One day, soon enough, we’ll dig deeper into this part.</p><h3>Project management</h3><p><em>What tools to keep eveyone busy and productive</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*KeT0f-IRx7itg5lMW3HFkg.png" /></figure><h4><strong>Methodology</strong></h4><p>Like many before us we used to be on <strong>Scrum</strong>. But then we changed to <strong>ScrumBan</strong> in order to lighten our ceremonies and be task-focused : We work on many projects at the same time. We do have a <strong>Azure DevOps</strong> kanban dashboard, but we keep having daily stand-ups and retrospectives.</p><h4><strong>Communication</strong></h4><ul><li><strong>Teams</strong> <br>teams is the communication platform we use. <strong>We work 80% of the time remotely,</strong> and teams works pretty well for video and screen sharing - although there many limitations in linux (like remote control)</li><li><strong>Google Workspace</strong> <br>full cloud office tools work well for us.</li></ul><h3>The Big Picture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*ZCIp6l8nqSc0nK4yQq2jUg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebbe2b20661b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/antvoice-tech/how-we-built-our-tech-stack-at-antvoice-ebbe2b20661b">How we built our tech stack at AntVoice</a> was originally published in <a href="https://medium.com/antvoice-tech">AntVoice Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we are streaming thousands of rows per second into BigQuery —  Part I: Google Cloud Dataflow]]></title>
            <link>https://medium.com/antvoice-tech/how-we-are-streaming-thousands-of-rows-per-second-into-bigquery-part-i-google-cloud-dataflow-9465fdcd436d?source=rss----b6cfc462c219---4</link>
            <guid isPermaLink="false">https://medium.com/p/9465fdcd436d</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[google-cloud-dataflow]]></category>
            <category><![CDATA[google-cloud]]></category>
            <dc:creator><![CDATA[Bastien Moyet]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 13:25:32 GMT</pubDate>
            <atom:updated>2023-11-27T08:14:59.984Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we are streaming thousands of rows per second into BigQuery — Part I: Google Cloud Dataflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wygmQ1NRmFmWCbb9" /><figcaption>Photo by <a href="https://unsplash.com/@sortino?utm_source=medium&amp;utm_medium=referral">Joshua Sortino</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>The Dataflow job we described in this article, can be found on our AntVoice GitHub account: </strong><a href="https://github.com/AntVoice/bq-streamer"><strong>https://github.com/AntVoice/bq-streamer</strong></a></p><h3>Context of Google Cloud BigQuery usage</h3><p>At AntVoice we have 2 main usages for our data:</p><ol><li>Provide some <strong>analytics dashboards</strong> to our customers to quickly see how their advertisements campaigns are performing.</li><li>Use this data to <strong>train our models</strong> to give the perfect recommendation for the good user</li></ol><p>As we are working intensively with <strong>Google Cloud</strong>, the technology of choice was <a href="https://cloud.google.com/bigquery">Google Cloud BigQuery</a> as it allows quick data ingestion and reasonable query time on very large datasets.</p><p>There are mainly 2 ways of loading data into BigQuery:</p><ol><li>You can stream data live from your services into your tables. Data are then buffered to be persisted later (few minutes generally)</li><li>You can write your data in <a href="https://cloud.google.com/storage">Google Cloud Storage</a> and then load them into BigQuery.</li></ol><p>We choose to stream data directly to BigQuery as it was the simpler approach for our small and growing company.</p><h3>Our first solution</h3><p>Back then, when we first implemented this service, we needed some flexibility and the volume of data to load was reasonable. So we first created a <a href="https://cloud.google.com/pubsub">Google Cloud PubSub</a> topic to treat all of our data inserts asynchronously in a dedicated micro-service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*7s97aPEte7tRoDS9QV3k6A.png" /><figcaption>Our first solution</figcaption></figure><p>It worked for a time but soon our service was overwhelmed and it began to crash often. Even adding new instances, we weren’t able to handle the growing throughput.</p><p>At that time we weren’t using <a href="https://kubernetes.io/">Kubernetes</a> yet, making it more difficult to scale properly to handle the growing load. So we searched for a more managed solution that was able to scale more or less automatically. And we found <a href="https://cloud.google.com/dataflow">Google Cloud Dataflow</a> that could potentially help us meet the demand.</p><h3>Why did we need to create our own AntVoice Dataflow job?</h3><p><a href="https://cloud.google.com/dataflow">Dataflow</a> is a Google Cloud managed service that handles flows of data like an <a href="https://en.wikipedia.org/wiki/Extract,_transform,_load">ETL</a>. For a given job you create, you can define where does the data come from, what to do with it and where to store it. Then Google Cloud creates and manages the VMs your job is using to process your data.</p><p>Google is providing simple ready-to-use job templates such as :</p><ul><li>Load data from the given PubSub topic</li><li>Write these lines into the given BigQuery table</li></ul><p>If you only have a few tables to stream to, that might suit you. However, at that time we already had approximately 20 tables to stream to. And we didn’t want to have 1 topic and 1 job per table given our currents volumes.</p><p>We finally decided to implement our own flow using <a href="https://beam.apache.org/">Apache Beam SDK</a>. And we chose Java to develop it, as it was close enough to our current C# and Scala stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*lybi7dTVYXM3JjGDMc3V_g.png" /><figcaption>Our Dataflow solution</figcaption></figure><h3>What are our Dataflow job advantages?</h3><p>The idea behind this BigQuery streamer job is to listen to a single PubSub topic for messages that contain the row to insert into BigQuery. Each PubSub message defines in its metadata the target dataset and table.</p><p>We also added the possibility for the JSON row to be gzipped to save cost on PubSub billing. Whether a JSON is compressed or not is also indicated in the metadata.</p><p>As shown below our job consists of 4 consecutive steps.</p><ol><li>We read incoming rows from a PubSub subscription.</li><li>We read all the information needed like the target table or the compression status. And if needed we uncompress it.</li><li>The 3rd step is a technical step which is batching our rows to insert several of them at the same time.</li><li>Finally, we stream the rows into BigQuery</li></ol><figure><img alt="Dataflow job graph" src="https://cdn-images-1.medium.com/max/642/1*ErpX3GVWUmPVrJkBy_rQJw.png" /><figcaption>Dataflow job graph</figcaption></figure><p>The metrics displayed in the screenshot are not representing the real throughput this kind of job did handle. We are now using this solution to stream only our most critical data. As you will see in a second article, we completed this Dataflow job with another kind of batch data loading to mitigate growing costs.</p><p>When we integrated all our data through this streaming job, it was streaming approximately 100 million rows every day.</p><p>This solution has 2 major advantages:</p><ul><li><strong>Knowing that every row entering PubSub will be streamed to the target BigQuery table</strong>. It allows for a precise customer reporting UI where they can find exact data.</li><li>You can very simply stream a new table inside this job since all BigQuery destination table information is sent in the metadata. <strong>Without ever changing your Dataflow job.</strong></li></ul><p>Since 2018, this Dataflow job is running smoothly. As soon as we have an entity in our C# code (or any other language, even Bash) that corresponds to a table schema, streaming to BigQuery is as simple as sending the entity JSON to PubSub with the correct metadata.</p><h3>What are the cons of using this solution?</h3><p>We have encountered 3 issues so far with this solution:</p><ol><li>When some messages are holding a <strong>malformed JSON</strong> that does not correspond to the table destination. In this case, the Dataflow job is reporting some BigQuery errors which can block some or all your job.<br><em>It happened to us a couple of times, but at the moment instead of designing an automatic solution, we preferred to handle those rare cases manually to be certain no meaningful data were lost in the process.</em></li><li>We tried to adapt the <strong>auto-scaling feature</strong> to our use case but we never managed to make it scale properly. <em>As a temporary fix, we set up a manual scale up and down in the morning and the evening.</em></li><li>Our Dataflow job was becoming very costly. Indeed, that solution requires paying for the <strong>PubSub throughput</strong>, the <strong>Dataflow job VMs</strong> and the <strong>BigQuery streaming cost</strong>. And as our customer base grew we were facing an increasing amount of data to stream every day. That represented a hefty cost to pay each month.</li></ol><h3>The next AntVoice solution to decrease Dataflow costs</h3><p>When we tried to diminish our Google Cloud billing we looked into the other way of ingesting data in BigQuery, which is loading them from Google Storage.</p><p>We created a system to write data in Google Cloud Storage on the go, and load them periodically into BigQuery.</p><p>This new way of loading data will be described in <a href="https://medium.com/antvoice-tech/how-we-are-streaming-thousands-of-rows-per-second-into-bigquery-part-ii-google-storage-loading-3e1236d8872f">the following post</a>.</p><p>To be continued…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9465fdcd436d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/antvoice-tech/how-we-are-streaming-thousands-of-rows-per-second-into-bigquery-part-i-google-cloud-dataflow-9465fdcd436d">How we are streaming thousands of rows per second into BigQuery —  Part I: Google Cloud Dataflow</a> was originally published in <a href="https://medium.com/antvoice-tech">AntVoice Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>