I want to test a sharding example using spring boot and mysql database. If I start my mysql database on jdbc:mysql://localhost:3306/test
and jdbc:mysql://localhost:3307/test
. Or I could also use the same port but different schemas for testing purpose. Can I use nginx to configure as a reverse proxy to connect to the db depending on the userid
(which would be my key for sharding? Or what is the best way to test it out. Is it better to shard at the application level itself. I would be using a springboot application for this.
It turns out that I was overcomplicating things. I needed to use a custom version AbstractRoutingDataSource along with multiple db configuration in spring to get it working. The whole solution can be see here