Can a new database help get Zynga back on track?

Social gaming pioneer Zynga (s znga) hasn’t exactly been killing it in the earnings department since going public, but a new database system might help change that. At the very least, it could let the company do some things previously out of its reach, such as serve real-time recommendations and ads, and create advanced multi-player games. Building a better product is usually a good first step toward turning things around.

The database in question is MemSQL, the eponymous offering from a startup company by former Facebook(s fb) employees Eric Frenkiel and Nikita Shamgunov. The company, which launched in June, speeds up database operations by using in-memory storage and its own unique technique for converting SQL into C++, similar to what Facebook does for its PHP code. Frenkiel told me that other big-name customers already using the product include JPMorgan Chase, Hitachi and NY Life.

As of early January, Dan McCaffrey, GM of platform and analytics engineering at Zynga, told me that MemSQL was already storing about 70 billion rows of game data — from the server and database logs right up to social interactions. Right now, the biggest use of the MemSQL system is analyzing data from servers and databases about an application is performing. Compared with the company’s previous MySQL setup, McCaffrey said, “we can detect problems quickly and react to them much more quickly.”

Is a more personal Mafia Wars coming?
Is a more personal Mafia Wars coming?

However, the deployment is just a few months old, and McCaffrey’s team has bigger plans for its new database. Among them is the ability to make decisions based on user behavior in real-time, rather than having to rely on pre-computed user segmentation and sampled datasets. That would mean applications could offer more-personalized decisions around in-game purchases or other recommendations, while Zynga’s burgeoning ad network could serve more-targeted and more-timely ads.

Both of these uses are important. Ninety-five percent of Zynga’s revenue currently comes from in-game purchases, although McCaffrey said it expects ad revenue to make up the lion’s share by 2015. Presently, Zynga pre-computes its user classifications nightly using its Vertica (s hpq) analytics system. If analysts want to query streaming data in real time, they can only do so against a sampled dataset that’s small enough to fit in memory.

With nearly 100 MemSQL nodes deployed already, Zynga can now store weeks worth of game data in memory versus merely days worth in its previous MySQL-plus-Membase setup.

In addition to improving the analytic process, the new database could help inspire entirely new types of games. McCaffrey noted that Zynga doesn’t have many games in which players interact simultaneously (most rely on players taking turns), nor does it have many multiplayer games. And although McCaffrey didn’t address the issue, one has to imagine Zynga’s expected foray into online gambling will also benefit from having a bigger, faster database to manage those real-time — and real-money — transactions.

One of the goals in the engineering group, he said, is “trying to introduce things that also get our game designers to think differently.”

Of course, a database alone isn’t going to make Zynga profitable and because MemSQL is commercially available, it’s hardly a trade secret. And as McCaffrey noted, although the experience has been good this far, MemSQL is still a small company and there’s a lot of work to do if it’s going to expand its presence throughout Zynga. But Zynga’s excitement about around a new database — and, in theory, it could have chosen any one of a number of new options — at least illustrates how critical the right technologies can be when trying to run a big business at web scale.