Too many connections

Ever since upgrading to Percona 5.7 (from 5.6) we’ve been getting a lot of “Too many connections” messages from one of our rails apps. I’ve increased the max_connection from 256 to 1024 with no effect. Is there anything in the way percona 5.7 handles connections (or sleeping connections) that would cause something like this?

Also, this doesn’t happen constantly, it is pretty unpredictable.

Current: mysql Ver 14.14 Distrib 5.7.18-15, for debian-linux-gnu (x86_64) using 6.3

There is no much difference on how two versions handle connections. One of the problems I usually see when people update from a major version to the next one is that some queries that used to perform well change their execution path to something different, probably worse. I recommend you to enable slow query log with long_query_time=0 and try to optimize those that take most of the database time.