📜 ⬆️ ⬇️

How we put together a 12-story technology stack and weren’t crazy

Appodeal is a company of ~ 100 people who work in Moscow, San Francisco, Barnaul, Lutsk, Kirov, Barcelona, ​​and since June 2018, also in Minsk.

We are engaged in the monetization of mobile applications by showing ads to users. We started with advertising mediation, but the technology stack is constantly growing, so other products from the Ad Tech industry were added to the mediation.

image
')
For those who are not yet familiar with Ad Tech - this is the area of ​​work of technology companies that work in the field of advertising. When you tell someone that you work in the field of mobile advertising, people often react skeptically - apparently, annoying ads “Azino Three Axes” come to mind. In fact, this is only the tip of the iceberg, and all this “wild” advertising has nothing to do with this advertising business. And the mobile segment, which we are engaged in, has long outgrown the segment of advertising on the web:

image

Why do I need to integrate advertising in applications?


Of course, many resources are spent on creating applications — and the creators / owners want the time and effort spent to pay off. Owners of mobile applications that spread their application in the App store / Google Play are called publishers or publishers. Publishers use different monetization models, from in-app purchases to monetizing through advertising. But of all these methods, only the latter allows the user not to pay for the use of the application - and this gives the greatest audience reach.

Yes, if there are too many advertisements, this will annoy everyone and negatively affect the user’s retention. Which, of course, no one needs. Therefore, advertising is always trying to integrate wisely, in order to earn maximum money on your application and at the same time not to take a penny from users.

How it works?


As soon as the publisher decides to monetize with the help of advertising, he comes to the company that can make this task as easy as possible for him. How does this happen with Appodeal? After registering on the site, we integrate its application with our service. This is done through the client SDK, which connects the application with the server part and communicates with the server part via the API.

If we reduce the details to a minimum, the goal of interaction is reduced to two stages:

but. Determine what kind of advertising you need to show right now;
b. Send information about which ad was shown and which was not, and display it in the statistics.

At the moment, Appodeal serves several thousand active applications that carry approximately 400-450 million ad impressions per day, received in response to about 1 billion requests to advertising networks (which are advertising providers). In order for all this to work, our servers in total serve about 125 thousand requests per second, i.e. approximately 10.8 billion requests per day.

image

What is all this built on?


We use various technologies to provide speed, reliability and at the same time development and support flexibility. At the moment we are writing code in the following languages:


image

Why initially Ruby and Ruby on Rails?


Appodeal competes in its segment with very large players, so it is necessary to adapt to market changes quickly. Often it feels like a car wheel change at a speed of 100 km / h. Ruby on Rails allowed us to endure the race and gain a foothold in the market enough to be the leader in its segment. The main advantages of Rails in our opinion:


image

Of the obvious cons:


image


How is the data stored?


We have a lot of data. Highly. These are billions / tens / hundreds of billions of records. Since the data is completely different, we store them in different ways. You should never be limited in architecture to any one solution that is supposedly universal. Practice shows that, firstly, in Highload there are practically no universal solutions. Versatility means average (or significantly lower than average) data on access / read speed / storage size as payment for this versatility. Secondly, you need to try something new all the time, experiment and look for non-trivial solutions for the tasks set. Total:


image

Nichosi! How can this not delete and modify data ?!


image

Such a set may seem overloaded, but firstly, Appodeal is a large conglomerate of several development teams and several projects within one. And secondly, these are the harsh realities of ad tech - we are far from being alone using a multi-storey stack within one company.

How do you follow this?



Since the data streams are large, in order to process them, the data must be added to the queue. As a queue, we use Kafka. This is a great reliable solution, written in Scala, which has never failed us.

image


The only requirement for the user in this case is that he has time to rake the constantly increasing queue faster than it grows. Simple and obvious rule. Therefore, for these purposes, we mainly use GoLang. However, this does not negate the fact that there should be a lot of RAM on this server.

To keep track of all this farming, you have to monitor and delegate literally everything. For this we use:


image

You need to understand that properly constructed monitoring is your eyes and ears. Blind work impossible. You need to see what happens on your servers at a particular point in time, so the stability and reliability of your product will depend largely on how well you build a system for collecting and displaying metrics.

By the way, speaking of reliability, we keep several staging servers for pre-rolling out and checking releases, which we consistently keep under load, duplicating some of the real traffic there. Every week we synchronize the databases between production and styling. This gives us a kind of “mirror” that allows us to test those things that cannot be tested locally, as well as to identify problems at the level of load testing.

Is it all so difficult?


It turns out that way. As Ilon Musk wrote in his book: “The best minds of my generation are engaged in how to get people to click on advertisements,” Jeff Hammerbacher, formerly an Facebook engineer, told me. - The horror ... ". A short list of what Appodeal does:


image


In this case, the so-called bidders are traded with each other online at the auction for the right to show their ads on the selected device. Very interesting moment worthy of a separate article. Many exchanges, such as Google AdExchange, set a rigid framework for the server response time (for example, 50ms), which raises the question of performance. In the case of disobedience - a fine of thousands of dollars. This is exactly what makes the kernel written in Scala in conjunction with Druid.

Every hunter wants to know where the pheasant sits, and our clients (like us) want to know who was shown the ads, when and why. Therefore, the whole bunch of data that we have, we have to put in a queue (Kafka), gradually process and add to the OLAP database (ClickHouse). Many people think that PostgreSQL will cope with this task as well as any other hipster solutions, but this is not true. PostgreSQL is good, but the classic solution for building indexes for data access speed stops working when the number of fields for filtering and sorting exceeds 10, and the amount of stored data approaches 1 billion records. You simply do not have enough memory to store all of these indexes, or there will be problems with updating these indexes. In any case, you will not be able to achieve the same performance as column-oriented solutions for analytical queries.

Conclusion


In this article I tried to at least briefly tell what we are doing, how we store and process data. Tell us in the comments which stack you use, ask questions and request new articles - we will be happy to share our experience.

Source: https://habr.com/ru/post/425357/


All Articles