Most of the Ads API have the same object model: campaign > ad group > ads. They might call an Ad in a fancy way (such as line item), but the hierarchy is more or less the same.

Because you can see so clearly what are the relationships between objects, you might think “let’s use MySQL,” create one table per object, make the relationships, and done.

I won’t say it won’t work, it will. Until two things would happen:

1) Read queries taking more than 1 minute to return thousands of ads’ stats
2) Breaking changes

If you are not familiar with breaking changes, they are an excellent way to test your database model. If Facebook decides to add another level in the hierarchy, you are looking at lots of ALTERs and migrating gigabytes of data (if you haven’t been there, it isn’t fun.)

Avoid caching data (you will get into the cache refresh problem) and design your database(s) to return thousands of rows in seconds and to be breaking changes proof. Elasticsearch and Cassandra are good starting points.


read more