This is a created article in which the information may have evolved or changed.
Check out the error log I wrote today and report the Too many connections
error. Have not seen ah, decisive to ask my eldest brother, he said is the problem of the number of connections. I went to see my code before it was online, only to remember that the database connection needs to set the maximum number of connections. This error is reported when the number of connections exceeds the range.
I'm using Xorm as an ORM tool, engine.SetMaxConns(dbMaxConns)
you can set the maximum number of connections directly.
Later, the cache was optimized. The general ORM also supports caching mechanisms. If the cache hits, it will not go to the database to find the data, but will return directly. Adding a cache requires increasing the cache time and the maximum number of caches.
cacher := xorm.NewLRUCacher2(xorm.NewMemoryStore(), time.Duration(interval)*time.Second, max)engine.SetDefaultCacher(cacher)
Very simple question, but always forget to add. Today, with a wrk
simple stress test on the project, this is the problem. I've always felt that stress tests are used to measure performance, and today we have a new understanding.
Original link: Database access to the cache and the maximum number of connections, reproduced please indicate the source!