From 1817b082e7f09ff692a5dbe7c560780ea2165f23 Mon Sep 17 00:00:00 2001 From: Arjun Kathuria Date: Thu, 2 Nov 2023 13:33:12 +0530 Subject: [PATCH] fix: Increase number of stripes to 4 in pool creation * We were running into throughput bottlenecks because it was found that the resource-pool was blocking requests. When The maximum resources per-stripe would get utilized and it would block. * This PR increases the number of stripes from the default 1 to now 4. * The number 4 was chosen here a it was found to be the number with maximum gains without losing stability in local load-testing. A full report on different numbers was presented and can be referred to for a fuller picture. --- src/Database/Redis/Connection.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Database/Redis/Connection.hs b/src/Database/Redis/Connection.hs index 95a2cfcb..940d727d 100644 --- a/src/Database/Redis/Connection.hs +++ b/src/Database/Redis/Connection.hs @@ -157,7 +157,7 @@ createConnection ConnInfo{..} = do -- until the first call to the server. connect :: ConnectInfo -> IO Connection connect cInfo@ConnInfo{..} = NonClusteredConnection <$> - createPool (createConnection cInfo) PP.disconnect 1 connectMaxIdleTime connectMaxConnections + createPool (createConnection cInfo) PP.disconnect 4 connectMaxIdleTime connectMaxConnections -- |Constructs a 'Connection' pool to a Redis server designated by the -- given 'ConnectInfo', then tests if the server is actually there. @@ -224,7 +224,7 @@ connectCluster bootstrapConnInfo = do let isConnectionReadOnly = connectReadOnly bootstrapConnInfo clusterConnection = Cluster.connect withAuth infos shardMapVar timeoutOptUs isConnectionReadOnly refreshShardMapWithNodeConn - pool <- createPool (clusterConnect isConnectionReadOnly clusterConnection) Cluster.disconnect 1 (connectMaxIdleTime bootstrapConnInfo) (connectMaxConnections bootstrapConnInfo) + pool <- createPool (clusterConnect isConnectionReadOnly clusterConnection) Cluster.disconnect 4 (connectMaxIdleTime bootstrapConnInfo) (connectMaxConnections bootstrapConnInfo) return $ ClusteredConnection shardMapVar pool where withAuth host port timeout = do