1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 09:42:41 +01:00
phorge-phorge/src/infrastructure/storage/lisk
epriestley 5e3efca08a In taskmaster daemons, only close connections which were not used recently
Summary:
Ref T11458. Depends on D16388. Currently, we're very aggressive about closing connections in the taskmaster daemons.

This can end up taking up a lot of resources. In particular, because the outgoing port for outbound connections normally can not be reused for 60 seconds after a connection closes, we may exhaust outbound ports on the host if there's a big queue full of stuff that's being processed very quickly.

At a minimum, we //always// are holding open a `worker` connection, which we always need again right away. So even in the best case we end up opening/closing this about once per second and each daemon takes up about ~60 outbound ports when it should take up ~1.

So, make two adjustments:

  - First, only close connections which we haven't issued a query on in the last 60 seconds. This should prevent us from closing connections that we'll need again immediately in most cases. In the worst case, we shouldn't be eating up any extra ports under default TCP behavior.
  - Second, explicitly close connections. We were relying on implicit/GC behavior (maybe as a holdover from very long ago, before we got connection wrappers in place?), which probably did about the same thing but isn't as predictable and can't be profiled or instrumented.

Test Plan:
This is somewhat difficult to test completely convincingly in isolation since the problem behavior depends on production scales and the workload, and to some degree on configuration.

I tested that this stuff baiscally works by adding logging to connect/close and running the daemons, verifying that they churned connections a lot before this change (e.g., ~1/s even at no load) and churn rarely afterward (e.g., almost never at no load).

I ran some workload through them to make sure I didn't completely break anything.

The best real test is just seeing how production responds. Current inbound/outbound connections on `secure001` are 1,200:

```
secure001 $ netstat -t | grep :mysql | wc -l
1164
```

Current outbound from `repo001` are 18,600:

```
repo001 $ netstat -t | grep :mysql | wc -l
18663
```

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11458

Differential Revision: https://secure.phabricator.com/D16389
2016-08-11 12:03:56 -07:00
..
__tests__ Various linter fixes 2015-08-11 22:36:55 +10:00
LiskDAO.php In taskmaster daemons, only close connections which were not used recently 2016-08-11 12:03:56 -07:00
LiskDAOSet.php Extend from Phobject 2015-06-15 18:02:27 +10:00
LiskEphemeralObjectException.php Delete license headers from files 2012-11-05 11:16:51 -08:00
LiskMigrationIterator.php Delete license headers from files 2012-11-05 11:16:51 -08:00
LiskRawMigrationIterator.php Add LiskRawMigrationIterator 2013-06-21 12:55:07 -07:00
PhabricatorDataNotAttachedException.php phtize all the things 2015-05-22 21:16:39 +10:00
PhabricatorLiskDAO.php Fix misleading error message when only cluster database masters are configured 2016-08-10 13:06:12 -07:00
PhabricatorLiskSerializer.php Extend from Phobject 2015-06-15 18:02:27 +10:00