skandragon / postgresql-connection-tester

A simple postgresql connection torture test.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postgresqm-connection-tester

This is a quick hack to abuse a postgresql database. It will connect to the URI specified in the envar DATABASE_URL (eg: postgresql://127.0.0.1/template1) and issue a pile of queries. The template1database,or any database with a table calledpg_typewith atypname string` column, will work. No writes are made.

The envar CONCURRENT_CONNECTIONS specifies the number of concurrent database connections to attempt. There is no syncronization, so it's possible some will finish prior to others completing. In my test, 100 (with a limit of 100 in the server) properly works. 101 fails with an error. 500 fails with a different error, perhaps related to the OS limiting TCP connection rate.

Example

CONCURRENT_CONNECTIONS=101 DATABASE_URL="postgresql://127.0.0.1/template1" go run main.go

About

A simple postgresql connection torture test.

License:Apache License 2.0


Languages

Language:Go 100.0%