mysqlshardingacid

mysql data sharding geographically


What is the common approach to data sharding based on regions? a.k.a GDPR enforcement - EU data stays in EU.

If I were to save users' emails in users table - I would need to keep data for US and EU people separated somehow. Example mysql table:

CREATE TABLE users(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        name VARCHAR(30), 
        email VARCHAR(30), 
        otherSensetiveData VARCHAR(30))

In general I just want to know how to solve this problem.


Solution

  • If you have a data residency requirement in the EU, then you either need two servers, or you need to store all the data in the EU.

    If you shard the data (split it over multiple servers), then unique keys in general have some complications.

    There are at least four popular solutions to generating globally unique id values:

    Sharding is a complex subject, and you need to choose the solution that works best for your app.

    I'd recommend you first talk to a qualified legal professional familiar with the GDPR, to confirm that you really have a requirement for data residency. In some cases, you don't, according to articles like https://www.mcafee.com/blogs/enterprise/data-security/data-residency-a-concept-not-found-in-the-gdpr/ (though that article is not legal advice).