I've started with mysql2, but then I've
I've started with mysql2, but then I've moved to a handcrafted mysql protocol implementation, hoping to avoid any unnecessary CPU overheads.
2 Replies
Are you indicating that this might be mysql2-specific rather than related to Hyperdrive? When using direct connection with mysql2 and with you custom implementation do you get similar cputime?
I've just ran a series of tests comparing various options for a somewhat-fixed workload. Here are my CPU time measurements, averaged from about 20 worker invocations each:
mysql2 driver: 90ms via HD, 19ms direct
custom driver: 67ms via HD, 12ms direct
custom driver with workaround('): 19ms / 8ms
for comparison, planetscale's HTTP-based driver: 12ms
(') the workaround introduces a 10ms sleep after a short (<1024b) packet is received during the response phase.
The worker runs two queries - one SELECT, the other UPDATE. The SELECT query returns 2500 rows, each one containing a single integer.