I'm trying to use k6 to stress test postgres queries.
I am running postgres through docker and allocated following resources through settings : CPUs: 4, Memory: 10 GB, Swap: 2GB and Disk image size: 280 GB.
When I did load testing for a query, everything works for up to 45 virtual users but once I increase that to 50 I'm getting the following error :
GoError: pg: could not resize shared memory segment "/PostgreSQL.440965520" to 182976 bytes: No space left on device
There are 3 tables (actor, actor_movies and movies). To keep track of which actor has played a role in which movie. I wanted to do a full-text search on 4 fields and so created a materialized view over the join of these tables, roughly around 3 million rows.
I think that the error says that there's not enough resource, but is there anything that I can do to mitigate this.
Please let me know if the question is not clear and if it's missing something.
Thanks :)
EDIT 1 As @jjanes mentioned in comments. Following things worked for me :
- setting max_parallel_workers_per_gather = 0.
- reducing work_mem from 4MB to 2 MB.
- Increasing the size of shared_buffers from 128MB to 256MB (it should've 15% of actual ram i.e 1.5 GB).
Then I started getting this error, which I believe is another config change. GoError: pq: sorry, too many clients already which can be fixed with another config change.