How to determine that the maximum size of the database file is exceeded, and switch the data insertion to the second server?
Usually it would be slower to do what you suggest.

Case 1 -- big disk.  With a good index, the time it takes to fetch a row is almost the same for a huge table as for a tiny table.

Case 2 -- table is split across multiple servers.  Now you have to try the query on one server, then move to another.  This seems like a lot more work.

Lets be specific...  Please show us the query that you are trying to optimize.  And show us SHOW CREATE TABLE.  There may be a simple way to make it run fast, regardless of the 2GB boundary you propose.