Simulating Data Sharding and Routing from API Server
Create a DB.
Run: mysql -u root -p < <path to set_db.sql>
Simulate Multiple Shards: Create 2 connections from our machine to the DB, simulating 2 different shards.
API Server Routing: our API server is aware of th DB topolgy, r.GET("/user/:userID", getUser).
The getUser function determines the appropiate shard based on the userID
Alternative: Instead of handling routing at the application layer, we could be using a Proxy Database. A proxy DB handles the routing and scaling behind the scenes, and automatically distribute traffic across different shards.