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

docs: guide on horizontal scaling & auto-scaling #1183

Open
tirumaraiselvan opened this issue Dec 11, 2018 · 21 comments
Open

docs: guide on horizontal scaling & auto-scaling #1183

tirumaraiselvan opened this issue Dec 11, 2018 · 21 comments
Assignees

Comments

@tirumaraiselvan
Copy link
Contributor

tirumaraiselvan commented Dec 11, 2018

Guide on horizontally scaling Hasura, setting up auto-scale and benchmarking how fast auto-scale works on a substrate like GKE.

@tirumaraiselvan tirumaraiselvan added the c/docs Related to docs label Dec 11, 2018
@coco98
Copy link
Contributor

coco98 commented Dec 11, 2018

@tirumaraiselvan Can you suggest a full list of topics / a skeleton that we need to cover? Would be easier for someone to pick this up then.

@tirumaraiselvan
Copy link
Contributor Author

Here is the list ( leaving it to @rikinsk to structure them ) :

  1. Can we run more than one Hasura instance?
  2. Attaching reverse proxy/ load balancer to run multiple Hasura instances
  3. Scalability of queries/APIs
  4. Scalability of Event Triggers
  5. Managing schema across multiple instances

@ecthiender ecthiender changed the title [Docs] Guide on horizontal scaling Guide on horizontal scaling Dec 12, 2018
@amesas
Copy link

amesas commented Dec 15, 2018

How to add more/remove hasura nodes without Downtime
How to add/remove/upgrade Postgres replicas without Downtime
Strategies for HA / Horizontal Scaling: backups, monitoring ( maybe prometheus? ), etc..
For complex setups, the hard part is not deploying it, but maintaining it: logs, upgrades, incidents, monitoring, etc...
Deploying it, is as easy a "copying and pasting" a blog post

@rikinsk-zz
Copy link

Tracked here #940

@dsandip
Copy link
Member

dsandip commented Mar 20, 2019

Now that #1182 is live, this seems to be a better-documented issue to documenting a guide on scaling.

@dsandip dsandip reopened this Mar 20, 2019
@litchfield
Copy link

litchfield commented Mar 28, 2019

Hasura seems to scale great, and easy enough to load balance and auto-deploy.

It's the load on Postgres caused by subscriptions that concerns me. Each unique, open subscription query generates an sql query every second.

My initial thoughts --

  • Read/write splitting would be helpful for horizontal scaling (easy and saves using a proxy)
  • Could subscriptions use temporary(?) triggers instead of polling? If not, maybe we could tune the polling frequency on a per-table basis?
  • Subscriptions should be optional on a per-table basis
  • Subscription permissions per-role ie "Allow role 'X' to use subscriptions"

@0x777
Copy link
Member

0x777 commented Mar 28, 2019

Read/write splitting would be helpful for horizontal scaling (easy and saves using a proxy)

#1847

Subscriptions should be optional on a per-table basis
Subscription permissions per-role ie "Allow role 'X' to use subscriptions"

I would prefer the per (role, table) at the server as it sits well with the existing system. The console can have UX for 'allow subscriptions for role 'x' on all tables'. #1892

It's the load on Postgres caused by subscriptions that concerns me.

This is changing very soon (end of this week, work in progress). The new architecture will cut down load on postgres significantly. We'll document the architecture.

@massimiliano-mantione
Copy link

This is changing very soon (end of this week, work in progress). The new architecture will cut down load on postgres significantly. We'll document the architecture.

Is this #1934 or something else?

I am evaluating Hasura and I have concerns about subscriptions scalability, I'd like to understand how they work... my use case could be subscription-heavy.

@dsandip
Copy link
Member

dsandip commented May 13, 2019

@massimiliano-mantione Yes, the optimisations to subscriptions did go as part of #1934 and a couple of other small PRs. These changes make subscriptions highly scalable. We are a few days away from publishing numbers from performance benchmarks.

What kind of scale are you expecting? (You can DM @coco98 /@tanmaig#8316 or me / @sandip#8048 on the community Discord server if that's preferable)

@pjoe
Copy link

pjoe commented May 16, 2019

Very interested in this too, also have a potential workload that would be very subscription heavy and require high scalability.

Are subscriptions still polling the db after latest optimizations?

@marionschleifer marionschleifer self-assigned this Jul 10, 2019
@marionschleifer marionschleifer added p/medium non-urgent issues/features that are candidates for being included in one of the upcoming sprints e/intermediate can be wrapped up in a week labels Jul 10, 2019
@riccardogiorato
Copy link

Any news on the subscriptions polling the db as @pjoe already asked?

@marionschleifer
Copy link
Contributor

marionschleifer commented Aug 14, 2019

@pjoe @giorat sorry for the delay in answering your question.

I would like to refer you to this article: https://github.com/hasura/graphql-engine/blob/master/architecture/live-queries.md. This talks about the current architecture and about how we can handle 1M concurrent subscriptions in our benchmarks.

Let us know if you have any additional questions 🙂

@coco98 coco98 changed the title Guide on horizontal scaling Guide on horizontal scaling & auto-scaling Sep 5, 2019
@hrgui
Copy link

hrgui commented May 2, 2020

Is there a way to scale horizontally / vertically in kubernetes w/ the cli-migrations container?

Or should the process that does the migrations should be separated from the scaling? Because I imagine, if we run 3 of the cli-migrations container, they will all attempt to lock the DB due to migrations.

@shahidhk
Copy link
Member

@hrgui You can scale the cli-migrations image to multiple replicas. When a new rollout happens, the default strategy on kubernetes is that it will replace pods one by one. Hence, only one pod of the new rollout will be running at any point and once that finishes applying migrations, other pods will just skip migrations.

This will need health checks to be configured too.

@beepsoft
Copy link

Hi,

is this guide still in the making? I am specifically interested in whether running Hasura on Google App Engine Flexible Environment (#1550) or Google Cloud run is possible now? There are these other issues #1078 and #940 that point here but then I could not find any reference to a scaling guide.

So, is this/will this be available somewhere?

Thanks!

@kenptr
Copy link

kenptr commented Oct 29, 2020

For anyone wondering how to run graphql-engine on GAE (Google App Engine):

Dockerfile

FROM hasura/graphql-engine:v1.3.2

app.yaml

runtime: custom
env: flex
service: hasura

network:
  session_affinity: true

liveness_check:
  path: "/healthz"

readiness_check:
  path: "/healthz"

env_variables:
  HASURA_GRAPHQL_DATABASE_URL: postgresql://USER:PASS@IP_ADDR/DATABASE

@mdemierre
Copy link

mdemierre commented Nov 5, 2020

@hrgui You can scale the cli-migrations image to multiple replicas. When a new rollout happens, the default strategy on kubernetes is that it will replace pods one by one. Hence, only one pod of the new rollout will be running at any point and once that finishes applying migrations, other pods will just skip migrations.

This will need health checks to be configured too.

@shahidhk Is it still valid for the v2 migrations? Now that metadata is separate, I can see the following scenario:

  1. We have 3 instances of the cli-migrations image running (pods, VMs, whatever).
  2. We deploy a new version with modified metadata and migrations
  3. The migrations start to auto-apply from the first updated instance, it updates the migrations and metadata
  4. A random instance crashes and is restarted with the old config
    • It tries to reapply the old migrations: OK, no conflict because of transactions + will not apply already applied stuff
    • It tries to reapply its metadata: BOOM, we have old metadata
  5. The next upgraded instance will fix it

Between 4 and 5 we risk unavailability I think due to incorrect metadata. Is this a possible scenario?

I think an horizontal scaling guide covering migrations and so on would be useful to have.

@jync
Copy link

jync commented Nov 12, 2020

Hi... would absolutely love to know exactly what Hasura is thinking of in terms of horizontally scaling. A guide will go a long way to help the community understand.

I'm also looking at this - #1182 and #1574

It appears the metadata update once it hits the DB will trigger all instances connected to the DB to update? Is this correct?

How does this work with a rolling update across a cluster? Will it signal ALL instances to update then? Won't that break the rolling deployment?

@mdemierre
Copy link

mdemierre commented Nov 12, 2020

@jync Thanks for the links to other issues. It indeed seems that #1574 made it so the metadata will be automatically reloaded by all running instances.

Does that make the scenario described in my other comment (#1183 (comment)) even worse (a faulty instance restarting and overriding the metadata with an old version)?

@jync
Copy link

jync commented Nov 12, 2020

I've seen Hasura not start if the hdb_catalog is from an older version of hasura.

If metadata versioning is incorporated, I'd imagine you do something similar? (ie no-op if the incoming schema version is higher than the version found in the metadata files)

But I'm not sure if there is metadata is being versioned. There is a metadata/version.yaml file but I think this captures the metadata schema version (ie the version that hasura understands).

@marionschleifer marionschleifer changed the title Guide on horizontal scaling & auto-scaling docs: guide on horizontal scaling & auto-scaling Dec 8, 2020
@marionschleifer marionschleifer removed their assignment Dec 8, 2020
@marionschleifer marionschleifer removed e/intermediate can be wrapped up in a week p/medium non-urgent issues/features that are candidates for being included in one of the upcoming sprints labels Dec 8, 2020
@serefarikan
Copy link

After spending the last 30 to 45 minutes trying to figure out what is meant by horizontal scaling and auto scaling, I gave up and decided to ask under this issue :)

according to https://hasura.io/learn/graphql/hasura-advanced/performance/2-horizontal-scaling/

"Hasura Cloud lets you scale your applications automatically without having to think about the number of instances, cores, memory, thresholds etc. You can keep increasing your number of concurrent users and the number of API calls and Hasura Cloud will figure out the optimizations automagically. But you could have a bottleneck at the database level which is when you might want to scale the database."

Based on the rest of the text on that page: horizontal scaling is hasura figuring out read reqs should be routed to read only replicas, while write reqs. end up routed to master.

What is auto scaling then? It is listed as a feature of cloud version here: https://hasura.io/pricing/ but this issue clearly separates horizontal scaling from auto scaling as per its title, so where is the definition of auto scaling?

By the way, the discussion jumps to #940 then to #1078 and then comes back to this issue, with no references to some documents I can read, at least as far as I can see.

I know it's Friday and I ran out brain cells, so if someone can point me at some documentation that explains the above, it'd would be much apprecaited :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests