I came across the google-cloud-spanner gem for Ruby.
Using session.commit { |c| c.insert(table, row) }
I can insert into Cloud Spanner easily.
However, I cannot exceed more than ~200 inserts per Second this way (from a computing instance in the same region).
In order to increase performance, I would have to pass an Array of rows to the insert method: c.insert(table, [row, row, row,...])
.
Why is Cloud Spanner working this way? Could this be due to networking overheads?
Inserting multiple records together is not always practical on my application layer.
EDIT:
Full example that shows creation of spanner client, etc:
spanner = Google::Cloud::Spanner.new(project: ..., keyfile: ...)
session = spanner.client(instance, database)
# Insert:
session.commit { |c| c.insert(table, row) }