# FEDERATED Engine: How to safely close connections

**URL:** <https://forums.percona.com/t/federated-engine-how-to-safely-close-connections/14990>\
**Category:** Other MySQL® Questions\
**Tags:** closed-no-reply\
**Created:** [March 30, 2022, 1:01pm UTC](https://forums.percona.com/t/federated-engine-how-to-safely-close-connections/14990 "2022-03-30T13:01:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitone](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bitone](https://forums.percona.com/u/bitone)\
**Post date:** [March 30, 2022, 1:01pm UTC](https://forums.percona.com/t/federated-engine-how-to-safely-close-connections/14990/1 "2022-03-30T13:01:27Z")

</div>

Hi there  
I know that this is not an issue specific to Percona. But we are using the Percona binaries and I’m sure that I can find competent people here 😉

FEDERATE engine opens a lot of sessions, over which I would like to have some control.  
These sessions seem to be closed only when the FEDERATED tables are flushed. Our issue is that all these connections consume a lot of threads on the master server, but actually are in sleep state most of the time.

Unfortunately the most obvious approach to solve this does not work: FEDERATED does not cope well when the connections are closed from the remote side. Hence flushing seem to be the only solution.

I would like to write some sort of script that flushes tables when they haven’t been used for a certain time. But till now I couldn’t find any meaningful information to decide which tables to flush to release unused resources.

Any hint will be greatly appreciated!  
Cheers,  
Till
