Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better documentation for -max_connections flag #498

Closed
zepouet opened this issue Oct 11, 2020 · 6 comments · Fixed by #621
Closed

Better documentation for -max_connections flag #498

zepouet opened this issue Oct 11, 2020 · 6 comments · Fixed by #621
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: docs Improvement to the documentation for an API.

Comments

@zepouet
Copy link

zepouet commented Oct 11, 2020

Feature Description

To be able to limit the number of connections or requests on the database via the proxy.

In the case of a container for which we do not master the code but also the configuration, it would be good to be able to limit, as well as the memory, the CPU ... the fact of calling too much Google Cloud SQL.

For example if you have 20 pods using the same CloudSQL instance with 20 databases, one nasty pod that consumes too much I/O from the DB could penalize other application pods.

In all highly shared environments, it would be a big advantage to protect yourself from this kind of side effect.

Obviously if we have control over the code and the applications, it is the developers' duty to configure the connection pools, but in the opposite case, we have to create x Google Cloud SQL instances to protect ourselves but often customers do not want and cannot.

Alternatives Considered

Either use existing features of MySQL and Postgre drivers or implement this on the proxy side to have something uniform

Additional Context

@zepouet zepouet added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Oct 11, 2020
@shubha-rajan shubha-rajan added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Oct 12, 2020
@zepouet
Copy link
Author

zepouet commented Oct 13, 2020

@kurtisvg If you need help later about it, it will be nice to participate. Thanks

@kurtisvg
Copy link
Contributor

Hi @zepouet - Can I get a better sense of what specifically you want limited? Do you want _rate_limiting specifically?

The original issue mentions both number of connections and requests. There are currently limits for both - you can limit the number of connections with the -max_connections flag, and the requests made through the sqladmin api are rate limited to 2x per minute. Are you hoping for more control over these limits, or hoping to limit something else?

@Carrotman42
Copy link
Contributor

Carrotman42 commented Oct 13, 2020 via email

@zepouet
Copy link
Author

zepouet commented Oct 15, 2020

Thanks @Carrotman42 @kurtisvg

To be honest I didn't test with this option because I didn't know it.
I don't find any references in the documentation and I am silly not to search with help command.
So maybe you solve my problem.

My usecase is a production platform with GKE and one Google Cloud SQL instance (Mysql)
We have many K8S deployments (200) and each deployment has a dedicated database on the same Cloud SQL Instance.
For cost reasons we have WAF in front of a number of pods but we cannot put it in front of all pods.
So if we have a DDOS or just a foreseen performance test (with Gatling or JMeter) on a dedicated website, we could penalize other website due to the common database. The pods use the sidecar pattern with application and cloudsqlproxy.

My idea is to have a way to limit Request and Database connections to isolate less critical websites.
Thanks to you, it seems to have a limit on connection so we could be nice.
Ideally with a request rating, it will be perfect so the sidecar container could play a complete work.
Maybe I am wrong.

A solution would be to create a dedicated Cloud SQL Instance for critical websites but I wonder how to rate limiting a pool of websites.

Maybe add this option to the online documentation for other guy like me :)

Thanks you very much for your comments.
Nicolas

@kurtisvg kurtisvg added type: docs Improvement to the documentation for an API. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Oct 15, 2020
@kurtisvg kurtisvg changed the title Rate limiting for connection and/or requests Better documentation for -max_connections flag Oct 15, 2020
@kurtisvg kurtisvg removed the priority: p2 Moderately-important priority. Fix may not be included in next release. label Oct 15, 2020
@kurtisvg kurtisvg removed their assignment Oct 15, 2020
@kurtisvg kurtisvg added the priority: p3 Desirable enhancement or fix. May not be included in next release. label Oct 15, 2020
@kurtisvg
Copy link
Contributor

@zepouet here are some broad recommendations:

  1. Use different instances over just different databases on the same instance if the database is otherwise unrelated. It's (usually) better to run smaller more isolated instances instead of bigger pooled instances so your failure points are separated.

  2. A more engineering heavy option to limit/optimize throughput would be to use a connection or transactional pool (something like ProxySQL or Pgbouncer). You could deploy this as a service with a proxy sidecar, and have different services per deployment (or groups of deployments depending on the situation). This involves a bit more work as you now have to manage things like encryption and cross zone/region traffic to these services. It can also give you other options like specify replicas.

I would still recommend application level connection pooling basically always.

@zepouet
Copy link
Author

zepouet commented Oct 15, 2020

Thanks @Carrotman42 and @kurtisvg for your help.
Better title and good solution.

Have a nice day and thanks a lot.
Best regards
Nicolas

@enocom enocom self-assigned this Feb 10, 2021
enocom added a commit that referenced this issue Feb 23, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
enocom added a commit that referenced this issue Feb 23, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 23, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 24, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 24, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 25, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 25, 2021
This commit cleans up the project README and cleans up the message
printed by the `-help` flag.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 25, 2021
This commit cleans up the project README and cleans up the message
printed by the `-help` flag.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 26, 2021
This commit cleans up the project README and cleans up the message
printed by the `-help` flag.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
enocom added a commit that referenced this issue Feb 26, 2021
This commit cleans up the project README and cleans up the message
printed by the `-help` flag.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
gcf-merge-on-green bot pushed a commit that referenced this issue Feb 26, 2021
This commit cleans up the project README and consolidates all additional
documentation into the docs folder.

Fixes #362.
Fixes #599.
Fixes #498.
Fixes #401.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: docs Improvement to the documentation for an API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants