Search code examples
postgresqllinode

Postgresql and Web application on a single core


There are case Postgres will insert new record into table each time user visit every pages, will Postgres be slow if web application use >98% of the CPU usage for incoming requests or what can be improve RPS in Linode VPS 1 cpu core on Ubuntu 15?

Or are there anything wrong with the created table?

CREATE TABLE "mysession"
"token" varchar NOT NULL,
"username" varchar,
"created" int4 NOT NULL DEFAULT 0,
"updated" int4 NOT NULL DEFAULT 0,
"idle" int4 NOT NULL DEFAULT 0,
PRIMARY KEY ("token") NOT DEFERRABLE INITIALLY IMMEDIATE ) WITH (OIDS=FALSE);

Solution

  • PostgreSQL is not likely to be a bottleneck on CPU for INSERTS. If it is you may consider

    • turning on asynchronous_commits.
    • disabling wal_logs

    There other options as well that are documented in the Non-Durable Settings doc.