Announcing Hasura Cloud: Managed GraphQL for your database and services
Tags: cloud, graphql, hasura
Published: 2020-07-09 05:03:39

---
title: Announcing Hasura Cloud: Managed GraphQL for your database and services
published: true
date: 2020-06-22 16:23:28 UTC
tags: Cloud, GraphQL, Hasura
canonical_url: https://hasura.io/blog/announcing-hasura-cloud-managed-graphql-for-your-database-and-services/
---

I’m delighted to announce the public beta of Hasura cloud!

Try it out here: [cloud.hasura.io](https://cloud.hasura.io)

![](https://lh5.googleusercontent.com/R2uL9Fj-4AWJUcxvtOdZhwzhGuQTOQbmcrruPRASiiHvGjzCQ69Mu3GEvMtS8jXXGEzHlIsfQ-celqWyjtxZiuLolo5TLYDj_9-NcQIFeSa_ussYSlCLtGNwV20jBrygMjKaBGkw)

This has been something we’ve been working on since January this year. We’ve used the core Hasura GraphQL engine as a base, made sure that we’re able to provide Hasura as a cloud offering where you don’t think about the number of instances, cores, memory, concurrent users, high-availability, realtime monitoring, caching, tracing, rate-limiting and other things that are infrastructure concerns and not really things you want to spend time on.

![](https://lh6.googleusercontent.com/UsPECvdOs9dA-YVy0uhburlOl8d1HNcXlV5Iwri--CAfRRWsIWRdwJWaur8skEkMa-0Uo-20Kk1c-rGpyfvqfaCFcPCi6k5hf1zaTPqUt7ey13jIpWGp_MP6H5FoEp7ivYI2cK51)<figcaption>Drake says, you ought to focus on building things, not running them!</figcaption>

For those new to Hasura, the Hasura GraphQL engine is an open-source service that uses a metadata engine to connect to new or existing data-sources (like Postgres, REST APIs, GraphQL APIs etc) and provide a managed and secure GraphQL endpoint that internal or external applications can connect to.

We want to make GraphQL _invisible_ to API developers, and give API consumers a GraphQL API they love. The logical next step for us, was to make Hasura GraphQL engine available as a managed cloud service.

![](https://lh4.googleusercontent.com/W9xkjiv90NVNN1RF9gsAQ52wetnCUf0gtEHo7Jc2Qlif4uXCHh_6pje8v0xbKCB4Vc1tUWpMq7Zys1ufDveIGzBT8Bre--XD8jiaIt3NwbJ6GtKl7Sl8RX6vQZjEr6ajAONmQjlC)<figcaption>From hosting and running Hasura yourself, to Hasura Cloud.</figcaption>

### Auto-scale and serverless GraphQL

Each instance of Hasura is a heavily multi-threaded server that exploits shared memory within the instance to aggressively optimise handling GraphQL queries at runtime. If you’re running Hasura yourself, you can first scale a few Hasura instances vertically and then horizontally. At what CPU or memory threshold should you scale up or scale out? Well….it depends. Hasura’s footprint is different for different kinds of workloads.

If you’re running on Hasura Cloud, you don’t need to care! Hasura cloud doesn’t ask you to think about the number of instances, cores, memory, thresholds etc. Hook up your database and other services, and it just works.

You can keep increasing your number of concurrent users and the number of API calls and Hasura Cloud will figure out how to make sure that your GraphQL API just keeps on giving. 🤓

Ultimately, your API performance will bottleneck on your database. Hasura Cloud ships with monitoring and tracing features that help you understand database query performance and give you insight into what to do. Most DBaaS vendors make it really easy to scale your postgres vertically, or add read replicas to your primary Postgres server.

![](https://lh5.googleusercontent.com/jkZlgFKbBQv4P1IGTreDO3iq28ww3Khrbl0lKJ_bTFUMQjTMn2gXTxydl1gGDBtwSmBitXp89xmMdWrr5vwFXVRgp-HJeGerVXKMsAkBAVRPIHYax4-BC3oDeKjZwjhj1C0E5JIi)<figcaption>Use SQL query analysis built in to Hasura to improve your database performance</figcaption>

Incidentally, if your upstream services are also written in a stateless way, especially if you’re using Actions with serverless functions or auto-scaling containers, then these will get automatically scaled by the cloud vendor too. 🤘

![Hasura Cloud is like a SaaS offering of your own data.](https://hasura.io/blog/content/images/2020/06/Screenshot-2020-06-22-at-9.14.34-PM.png)

### GraphQL caching (👋 @cache)

**TL;DR:**

- Hasura GraphQL Engine already supports query caching
- Hasura Cloud supports data caching by adding an @cache directive to your queries  

**GraphQL query caching**

Hasura GraphQL Engine already offers query caching where the internal representation of the fully qualified GraphQL AST is cached, so that it’s plan need not be computed again. For example, when a GraphQL query with variables and session variables comes in, the generated SQL is already prepared as a statement and exact end-user session based variables and the dynamic API variables (query variables) are zoomed through to the database. This makes Hasura’s queries extremely fast.

**GraphQL data (response) caching**

Hasura cloud goes a step further and adds support for data caching. We’ve taken the first step, and there’s lots more to do, but here’s how Hasura cloud thinks about caching which is something we API developers usually build inside our app server.

There are many purposes to application level caching, but the most common requirement is usually to reduce the load on the underlying data-source.

Caching authenticated API calls automatically is very hard/painful, because of 2 main problems:

**Knowing what to cache given an incoming API call made by a specific end-user:**

1. If the API call doesn’t depend on a property of the user, then it is straightforward to say that all API calls will fetch the same data. The cached data can be retrieved from a cache and sent to the API consumers.
2. If the API call depends on the property of the user, then we need to know if because of the identity of a user, they would end up fetching the same data that some other user has already cached. Let’s say everyone in the same area fetches the same list of restaurants on their app. This is a dynamic rule, because users can change their current areas and hence which cached entities are fetched depend on _who_ is making the API call at that point.  

![](https://lh3.googleusercontent.com/Yf7ULMs9ohLwC2TWF06O_u4ANWCFclpgURM3tUZyCFY4ieJmDGeXo-hpxFGjW9qTlkBEqIzabMsUWQeFpOEFEHFzb82ogrvHfnbTrDIQuXYv_Nn2dg0tlmVKjYKvbfpRFizpzZQQ)

> There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.
> 
> — Leon Bambrick (@secretGeek) [January 1, 2010](https://twitter.com/secretGeek/status/7269997868?ref_src=twsrc%5Etfw)

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

**Knowing how to update the cache**

1. Cache invalidation is hard :)
2. When users make API calls that perform writes, busting the cache that the same API server or that other instances of the API server are using, is hard.
3. This is a version of the materialized-view-dynamic-update problem, but at the application level which is potentially fetching from multiple data sources. This is typically why most application server developers using something like Redis typically set a TTL using information from #1 (Knowing what to cache) and deal with the temporary staleness on the UI side.  

![](https://lh6.googleusercontent.com/DASJ0Zh84yTslAbFoK8II2M6iqnJwklPMljKSEXZTxJTx3JpTJOD8F3QtYDQiwuDnavcAUmxGN0zEtc50Zgn2u8-gt_JOhuLV8sBHgBgcSfl8qB7vWLhBebnjmrdzQ54QA6TnInQ)

Because Hasura has enough information about the data models across data sources, and the authorization rules at the application level Hasura has enough information to offer end to end application caching by solving all the problems above.

Today, we’ve launched support for caching authenticated GraphQL API calls that works for shared data (problem 1). How do we handle cache invalidation today? We use a TTL configuration so that state data is refreshed within a time interval.

The good news is that since API writes and workflows pass through Hasura (GraphQL mutations), Hasura can eventually handle automatic cache invalidation too!

![](https://hasura.io/blog/content/images/2020/06/Screenshot-2020-06-22-at-9.17.20-PM.png)

### GraphQL Monitoring

Apart from monitoring successes errors (and partial errors) from GraphQL API calls and their responses, Hasura Cloud also adds great support for monitoring websocket connections and subscriptions!

![](https://lh5.googleusercontent.com/FVZuchaw6kG9RxJ5Wr9wQZDHbKqKO8QMbAF1f5DInudMautRIP41-LO6jYGGOzBVtViCLXbmFnfBaPbPLCtOcmeMOade8RX61RM3WXQjNeXKjyn11XHzywV1ebDVpbRviDzLnes5)

![](https://lh3.googleusercontent.com/IvohKi5jm-J7VJwwMDCZZmFTxE8yrBB704VS4nqtTc0yGUdwP8uMkZlbShNqlVtqrHDD653zOiRNl4vCPF9VJu2wjuOMEXGfp8llSGaIzKKe0FmW9bGv-ik3hT5lgyKbe0GaSKfz)

![](https://lh5.googleusercontent.com/B-ojRAgXqTWnnNIwBhZsKJU4tqR_JBpSFy8xUQ4A0LX6DQ0O6ifXADIKLov_SZ9E_7XaI_HRdUlelveKv2oHRc55r9cGPfFptU0Zeu2JjQIMWm4H52O9CLv2SA3myBAU3YOD9QlC)

### GraphQL Tracing with OpenTracing

Strange things happen in production and it’s hard to know where the problems came from. Tracing requests and responses, end to end and through the various components in your system in production is critical.

Hasura acts as a fulcrum and coordinating point between your GraphQL API consumer, your data models and your custom business logic or external services that you bring in via HTTP (GraphQL Remote Schemas or REST API Actions or Event Triggers).

![](https://lh5.googleusercontent.com/TN3mU_I1zlV--yvI-dtsqyk2Bg5W0xxYZGAenkyXDkcfm6PtTIl6alNq7TCj9pcx3We10TW_Z8UUrlr6MLeM5CH4IpIhLvLEglEfeYD1uggJtyMFnDEljO_x8R5LTNv_ELXe10QJ)

![](https://lh3.googleusercontent.com/WuDyS2aNBz2r_AvPGs8F4JI556zXw6LXAk7WeIp3D3i6ZhJ0FVYXuBNaNLorzWByVR7j5j46pPRzg3DqKkSAvbg4FzduOp8lJz6J0mwdkfY5nJ_VZkkwQbSg4Sbqm6CtNO0xTBK4)

Hasura Cloud adds a deep integration with OpenTracing, so that it can create traces, or respect incoming trace spans. Haura also forwards trace-ids and span-ids to services so that a distributed trace can easily be collected across your entire system. For example, this is what a trace collected from Hasura forwarding to an Action, that interacts with the database, whose response is then enriched by Hasura looks like when it's visualised end to end.

Today Hasura Cloud supports Datadog as a target to send traces to, and we’ll rapidly be adding more vendors that support OpenTracing over time.

![](https://hasura.io/blog/content/images/2020/06/Screenshot-2020-06-22-at-9.20.51-PM.png)

### GraphQL Rate limiting

When you’re running a GraphQL API in production, you might need to add some rate-limiting rules. Especially if your API is a developer facing API and not just used by an app. Rate-limiting allows you to make sure that your server and your data sources are protected from sudden spikes from malicious users and also allows you to make sure that your customers or tenants consume your API within reasonable limits.

Depending on what you want rate limiting to do, you need to maintain some state across various concurrent API requests to “count” your users’ limits.

Hasura Cloud offers rate limiting for unauthenticated users (based on IP) or parameterized by end-user session variables. Rate limiting rules can set a maximum number of requests per minute based on the parameters above, and can set query depth limits also. Over time, we will add support for dynamic query cost based limiting as well!

![](https://lh5.googleusercontent.com/zd7JHbe5cuZEs3kJL5YjTZy9m4_nTgRJV8-d0daCpqLiIgKqq44DPWpaj6F_t3NA-3i2BAwpLaIZnbBYH-x2PZ5sknialsZei_g5l3xjEhpX_tSAn6jRS_AqVp9AazeRsWrXrSlF)

### GraphQL Query capture

Hasura cloud captures queries (optionally stripping out session and query variables since they might be sensitive) and makes it available to you for 2 main uses:

1. Regression testing
2. Bootstrapping and managing an Allow List  

You can export the set of GraphQL queries and mutations that have been captured by Hasura in a given time window and then use it for all sorts of things.

**Regression testing:** You can run a test in the Hasura console or your favourite test runner against your staging environment as you make changes! This way, you’ll know if any changes you make to Hasura will affect GraphQL queries you’re seeing in production.

![](https://lh5.googleusercontent.com/-qY4n0hfLreRmWFBEHuI5n7bgxAOQl57mtokYxpowWXRWtf-ip3rreAETM5EXBNuAV7e7OPrmi96ni1WFHEGf8ABwtaknNyws7TQ6TuptmkQk4Nnk90J7fDwGYJzrhZZC-QBsZcy)

**Allow-list management:** You can also use the set of captured queries to create or update an allow list. For example, your staging project on Haura cloud can capture queries from your application testing suite and use that to help you build an allow list.

![](https://lh4.googleusercontent.com/ueq1yC-4HuuuiE99Z5LoG-zPVAMWbRvaSQRgsx0LdQncmy-AE3kppaVIQRluoX1RmOmJtSfbQlMFG_EX4WRC3IQ8teMyW-9kWo6uFB2DaIsdBAOhFbs2kQ7aeCUxG8H5-7j8d0Yt)

## Network security

Hasura connects to databases and services running on systems owned by you. For example, you can connect to Heroku Postgres, or RDS, or cloud SQL, or your own Postgres running on your VM.

While all communication between Hasura and your services can be encrypted TLS/HTTPS you might further benefit from ensuring that your database and your services only accept connections from Hasura anyway.

You can do this with:

1. IP whitelisting
2. VPC peering / private link

We’ve also started the process of getting our SOC2, ISO 27001 and HIPAA-readiness certifications so that it’s easier for you to start using Hasura Cloud in an enterprise environment. If you’d like to more, please get in touch!

* * *

![](https://hasura.io/blog/content/images/2020/06/Screenshot-2020-06-22-at-9.23.49-PM.png)

* * *

Try it out here: [cloud.hasura.io](https://cloud.hasura.io)