# Risk vs Reward: Real Money Gambling Application Architecture

In the first week of the 2021 NFL season, a bettor was famously one win away from a $727k payday on an 16 leg parlay. The problem? They lost. In a parlay, your position is only as strong as your weakest bet. The bettor’s downfall was relying on the overmatched Detroit Lions. When it comes to sports gambling, what the bettor doesn’t see is the technology that powers these user-facing applications that make or break their payday. Building a real money gambling application is actually much more complicated than it seems. Not only do you need a stable, reliable payment processing system, but you also need a real-time processing engine that can support millions of concurrent users who are placing bets at the same time. For real money gambling operators in the jam-packed mobile market, relying on a legacy RDBMS architecture might be a risky bet. ## Global Compliance for Online Gambling Industry No industry is more heavily and confusingly regulated than gambling. The US Wire Act, a pre-internet holdover, increasing scrutiny in Asia, and the EU’s GDPR all force operators to control the exact physical location of their data. While this might not sound like a huge issue, pinning data to a particular location can be rather complex. If you are using a solution that does not support the geographic distribution of data, essentially you need to build a new, siloed service for each additional region you want to do business in. Hypothetically, a group of talented engineers could string together multiple instances of a legacy relational database (such as MySQL or Oracle) and build a middleware layer which abstracts access from the application to hide the complexity of what’s happening beneath the hood. At that point, you’d essentially have built another database that you now have to maintain, and you might also be sacrificing transactional consistency. But there is a better way: domiciling data in close proximity to customers. CockroachDB’s geolocation capabilities give you the power at the database, table, and row level to restrict your user and bet data to the required physical location – even across multiple regions. Need to settle your bets in a New Jersey data center while your app runs in an AWS cloud region? Use CockroachDB’s simple multi-region SQL statements and online schema changes to move the data without a second of downtime. With CockroachDB, you can prove to regulators you have the capabilities and processes to comply with ever-changing data rules. One day, you may answer “Where does your data reside?” with a question of your own: “where do you want it to reside today?” ## Survival of the Fittest The global online real money gaming market size is expected to reach$127.3 billion by 2027, according to a report by Grand View Research, Inc. In this market, if your game is unavailable and showing the dreaded spinning wheel, your customer is a few taps of the finger away from spinning the roulette wheel in your competitor’s app.

When it comes to building a highly available application, you need to ensure you are reducing end-user latency and eliminating the possibility of downtime. An added bonus of data dominciling is that it provides low latency access to users in that particular region. Distributing data across multiple regions also increases fault tolerance to ensure that your betting services never go down.

CockroachDB takes this one step further with it’s multi-active resilient architecture. This means your database can survive the failure of node, availability zone, and even an entire cloud region, keeping players in your application. The next time a cable is cut in Malta and all your competitors are down, you can still be available and taking bets.

## Scale for Performance

It’s a happy day when you’re at the top of the Appstore leaderboard, if you can keep up. But more gamers = more transactions =  the need to scale your database to support the increase in traffic.

Supporting hundreds of thousands of concurrent users is no small feat. It can put a lot of pressure on your systems, create performance issues, and result in a poor end-user experience. To overcome this challenge, you need to be able to scale your database horizontally to support spikes in transactional workloads.

Many legacy databases (i.e. Postgres) reach their limitation when scaling vertically to accommodate an increase of traffic. And manual sharding is a pain. You also want your data to be evenly distributed which can create another operations hurdle if you are using the wrong solution.

CockroachDB does it differently – it allows you to scale your database horizontally across multiple regions which eliminates the need to ever have to manually shard. Adding capacity is as easy as pointing a new node at the running cluster, and CockroachDB takes care of the rebalancing. Building on CockroachDB’s scalable foundation prepares you for runaway success, even if you have a small team.

## Don’t Dismiss the Data Layer

Gambling companies require adaptable, flexible, and scalable components that support their application which will have several thousands of releases each year. In other words, they need to rapidly adapt to change to keep up with a competitive environment and retain their customers.

The key here is building on a resilient infrastructure that allows you to build quickly, and push out new features that are demanded by customers. When it comes to development, teams do not want to add complexity to the application, nor do they want long development cycles due to difficulties associated with scaling, replication, etc. They need to be able to get started quickly which can be hampered by inexperience, or complicated onboarding. Additionally, they need to be able to iterate quickly and adjust their deployment which is why agile development is so important to them.

CockroachDB eliminates the need to add complexity to the application layer because it takes care of the complexity for you at the database layer. This is done through CockroachDB’s horizontal scaling capabilities, ACID properties, and built-in replication. This greatly simplifies development for teams who don’t want to worry about the database and instead focus on building their application.

At the end of the day, real money gaming operators know that they need a data layer that is consistent, horizontally scalable, multi-region, and compliant. Ultimately, distributed databases are the best foundation for gambling applications, and forward-thinking operators realize that when it comes to real money gambling, there is no better choice than CockroachDB.

If you want to learn more about how CockroachDB fits in other industries you can take a look at our Gaming, FinServe, High Tech, Manufacturing, and Retail pages.

###### What is Change Data Capture?

CockroachDB is an excellent system of record, but no technology exists in a vacuum. Some of our users would like to …

###### Time, TIMETZ, Timestamp and TimestampTZ in PostgreSQL

We here at Cockroach Labs have been busy getting CockroachDB more in line with PostgreSQL for v20.1. This allows you to …

###### DASH: How to Evaluate Kubernetes-Native Databases

Cloud-native application architectures help developers deliver amazing experiences to their customers around the world. …

x