Cube Cloud Deep Dive: Starting a New Cube App
Tags: tutorial, opensource, analytics, bigdata
Published: 2021-11-23 15:11:46

Cube has been an [open-source project](https://github.com/cube-js/cube.js) since 2018. We try our best to listen to the community and our users to make it the best analytics API server on the market today.

We really appreciate all the help and sincere dedication our lovely community has done to provide feedback, submit pull requests, and feature ideas to improve Cube even more. We hope the soon-to-be 12,000 stars on GitHub are a representation of our dedication to making our community happy.

In this article, I want to walk you through creating a new Cube App deployment on Cube Cloud and connecting it to your database.

If you prefer watching a video instead, have a look at this short 5 minute tutorial on our YouTube channel.

<iframe height="500" src="https://www.youtube.com/embed/HVZ4ytDEjqc" title="YouTube video player" frameBorder="0" allow="fullscreen; accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture"></iframe>

Before moving on I want to share a bit about the benefits of using Cube Cloud vs. self-hosting Cube yourself.

## Why use Cube Cloud?

We [launched Cube Cloud this October](https://cube.dev/blog/announcing-cube-cloud/?utm_source=dev-to&utm_medium=post&utm_campaign=starting-a-new-cube-app-in-cube-cloud) with the vision of making Cube accessible to everyone, no matter the scale and DevOps experience level.

You already know Cube is an open-source project with almost 12,000 stars on GitHub. It's packed full of cool features, such as auto-generating schemas, auto-generating dashboards, a developer playground, and much more. It's easy to work with and developer-friendly.

Self-hosting Cube can come with its own set of complications due and pitfalls. Let me explain.

### Managed Infrastructure

[Cube requires several pieces of infrastructure](https://cube.dev/docs/deployment/production-checklist?utm_source=dev-to&utm_medium=post&utm_campaign=starting-a-new-cube-app-in-cube-cloud) to work reliably at scale. To get both high concurrency and high data size you need:

- Compute resources
- Redis
- Cube Store
- An API gateway
- A refresh worker
- A load balancer
- optionally, a VPC configuration

You can mitigate this by using infrastructure as code tools like AWS CloudFormation, Pulumi, or Terraform, and using Kubernetes as a container orchestrator.

![https://cubedev-blog-images.s3.us-east-2.amazonaws.com/783e7e2c-5205-4914-a96d-acfe3a136e65.png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/783e7e2c-5205-4914-a96d-acfe3a136e65.png)

### **Monitoring and Scaling**

Maintaining application up-time is a serious responsibility. To achieve this with self-hosting, you have to make sure that monitoring is configured for Cube and that you can scale Cube up if there's a spike in traffic.

With Cube Cloud, both monitoring and auto-scaling are available out-of-the-box.

You also get query monitoring in the Queries tab in the sidebar. The entire query history is available, including metrics like query result size and time spent, helping you dig into why some queries take longer than others.

![frame_chrome_mac_light_(72).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/0844659b-c006-4d75-98b8-7984a82fee81.png)

You can see application performance metrics in the Metrics tab.

![frame_chrome_mac_light_(73).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/b6d12fca-de08-46f8-b736-930969e651a4.png)

### **Caching**

A major problem when scaling Cube apps is optimizing pre-aggregation build times. Similarly, when trying to determine the status of your pre-aggregations; you need to know whether they're built or not and when they were built.

In Cube Cloud, we can check out the Pre-Aggregations tab to see the status of all pre-aggregations in your Cube deployment, including whether they're building or not and even which of the partitions, if any, are being refreshed.

![frame_chrome_mac_light_(74).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/7f43d038-6d95-4e91-bd31-90b8a6feca2c.png)

In production, these pre-aggregations are kept up-to-date automatically for you.

### **Development Tools**

You get GitHub integration with Cube Cloud. Your deployment can watch a GitHub repository for changes and deploy updates. Connect a deployment to GitHub from the Settings page and you're set.

![frame_chrome_mac_light_(75).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/3b1bf669-7c95-4746-baa0-951bfe2e6f60.png)

You can also make changes directly in the Cube Cloud console by entering Development Mode.

![frame_chrome_mac_light_(76).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/3c74ca7f-58b7-44c4-9e88-d719ab93b325.png)

You get a dedicated Git branch, complete with a personal API URL and separate pre-aggregations.

### **Support**

If you have paying customers, having paid support is a lifesaver. If something breaks, and you need help fixing it, having someone to call is a lifesaver. Cube Cloud comes with support on the Enterprise plan, so you can ping us whenever you hit a snag!

## Sign Up to Cube Cloud

Signing up is simple and secure because you can also choose to sign up with your GitHub account. Here's how you sign up.

Jump over to the [sign-up page](https://cubecloud.dev/auth/signup) and enter your email.

![frame_chrome_mac_light_(57).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/651bf8cb-fedf-4f21-bac4-6879ff91633b.png)

Once you click `Sign Up`, you'll receive an email from us to set a password.

![frame_chrome_mac_light_(58).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/376a65f0-d828-4c10-a4b3-c56f8a86e5a9.png)

Next, you select a subdomain for your Cube Cloud account.

![frame_chrome_mac_light_(59).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/eab870f8-a430-4048-84d4-38e0c7238e08.png)

With all this out of the way, you can finally start creating Cube Deployments.

![frame_chrome_mac_light_(60).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/4c4c987d-dfa1-4591-8464-a3ec76a2f820.png)

Let me explain how to create a deployment.

## Create a Deployment in Cube Cloud

Creating a deployment consists of four main steps.

1. Create Deployment
2. Set Up the Cube App
3. Set Up the Database Connection
4. Generate the Data Schema

Let me break it down into even more detail.

### Step 1 - Create Deployment

The first step of creating a Cube App from scratch in Cube Cloud is to create a deployment.

Once you click the `create deployment` button it'll open up the first step in the deployment creation UI flow.

![frame_chrome_mac_light_(61).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/8edd42ca-a308-4cc5-a358-fb6324a28298.png)

Here you choose what name to give your deployment and pick the cloud provider and region. The reason why to choose either AWS or GCP is based on where you're hosting your own infrastructure and apps.

Let me give you an example. Let's say you have a metrics dashboard that needs to consume data on `us-east-1` on AWS. Using the same AWS region to host the Cube deployment as where you are hosting this metrics dashboard will reduce the network delay and latency between Cube and your app.

Which database you're using is also important when choosing a cloud provider and region. If you have data in BigQuery then you should not choose AWS. If you're using AWS Redshift then vice-versa applies.

### Need a Dedicated VPC?

A reason for using a VPC is if you expect high throughput of up to and above millions of requests per day. Using a VPC will give you a dedicated managed infrastructure that is ready to serve such high numbers of users.

Additionally, if your company required security compliance like SOC2, using a VPC is mandatory.

The best part is that a VPC is readily available for you if you need it. All you need to do is to reach out to us and ask for it. Super simple!

![frame_chrome_mac_light_(62).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/972709c6-6911-4c9e-910c-f316120698d7.png)

But, back to business. Let's get back to creating the Cube app deployment. After selecting a cloud provider and region, add a name for your deployment and click next.

![frame_chrome_mac_light_(63).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/f2455031-14b9-49ca-b449-eb113a8deda8.png)

### Step 2 - Set Up the Cube App

Next up, the second step in creating a Cube App from scratch in Cube Cloud is to click the `+ create` button.

![frame_chrome_mac_light_(64).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/0fe2ae4e-d596-499d-b26b-5f62f5780683.png)

But, before moving on, I want to ask if you already have a Cube app? If you do, please jump over to my co-worker Hassan's [guide on migrating a Cube app](https://cube.dev/blog/migrating-from-self-hosted-to-cube-cloud/?utm_source=dev-to&utm_medium=post&utm_campaign=starting-a-new-cube-app-in-cube-cloud) to Cube Cloud.

In this tutorial, I want to stick to creating a Cube App from scratch, so let me continue where I left off.

### Step 3 - Set Up the Database Connection

After selecting the `+ Create` button and proceeding to create a Cube app from scratch, you'll be prompted to select a database type. This lets you choose from dozens of the most popular databases available on the market today.

![frame_chrome_mac_light_(67).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/81442713-0261-424c-bb09-17b1601c10e0.png)

I'll proceed with selecting PostgreSQL to hook up a sample e-commerce database to show you how simple it really is. The values I'll use are:

```json
Hostname
demo-db.cube.dev

Port
5432

Database
ecom

Username
cube

Password
12345
```

In the UI it'll look exactly like the image below.

![frame_chrome_mac_light_(68).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/a0c30616-0a8e-4c85-8f79-4f9ba849eb63.png)

Once you click the `Apply` button, Cube Cloud will test if the connection was successful, and proceed to the next step.

If you run into issues here, make sure to allow the Cube Cloud IPs to access your database. This means you need to open up your firewall to these IPs. In the case of AWS, this would mean adding a security group with allowed IPs.

### Step 4 - Generate the Data Schema

Step four in this case consists of generating a data schema. Start by selecting the database tables to generate the data schema from, then hit `generate`.

![frame_chrome_mac_light_(69).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/a959643f-4e0f-4f62-9dc9-4d48a0405002.png)

Cube Cloud will generate the data schema and spin up your Cube deployment. With this, you're done. You've created a Cube deployment, configured a database connection, and generated a data schema!

![frame_chrome_mac_light_(70).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/4cd2de24-098f-465e-b7ee-dbadd3e82ab9.png)

You're ready for the last step, running queries in the Playground.

### Running Queries in Cube Cloud's Playground

By clicking on the Playground in the left nav you'll open the Playground UI.

Here you can test queries by selecting from all the measures and dimensions in the data schema. This lets you test different dashboards and visualizations for when you want to build your own metrics dashboards.

The image below showcases a bar chart with an **`Orders Count` measure**, an `**Orders Status` dimension**, and an `**Orders Created At` time dimension** **grouped by day for the current month**.

![frame_chrome_mac_light_(71).png](https://cubedev-blog-images.s3.us-east-2.amazonaws.com/56faf279-2d8c-4d98-97d3-cb960ea5413a.png)

You can use the playground as a testing ground for all queries you want to run in your own dashboards. The playground will also display how long a query took, showing you the response time above the chart itself.

That's it! You've finished creating a Cube Deployment on Cube Cloud.

### What About Query Acceleration?

Congrats! You've configured a Cube app in Cube Cloud. You're ready to add pre-aggregations and run the deployment in cluster mode. We have detailed tutorials explaining these concepts for you to read [here](https://cube.dev/blog/cube-cloud-deep-dive-mastering-pre-aggregations/?utm_source=dev-to&utm_medium=post&utm_campaign=starting-a-new-cube-app-in-cube-cloud). You can follow along with the tutorial to add pre-aggregations to your data yourself.

We at Cube also hosted a [workshop about pre-aggregations](https://www.youtube.com/watch?v=1_BP3B_wbec) that you can take a look at to learn more about query acceleration.

### Conclusion

Deploying a Cube App on Cube Cloud consists of four steps. First, select the cloud provider, region, and name. Second, select creating a Cube app from scratch, Third, connect a database. Fourth, generate a data schema.

You should keep in mind there are three ways of deploying Cube apps in Cube Cloud. You can create one from scratch, with the Cube CLI, or with the GitHub integration.

If you choose to use Cube Cloud, you'll get the added benefit of getting managed infrastructure that auto-scales to your needs. Cube Cloud also has some added features compared to self-hosting Cube, including query performance analysis, query response times, APM, and pre-aggregations enabled by default.

I hope you end up trying out Cube Cloud because you'll save time and energy by not managing infra and just focusing on building product value.

[Sign up to Cube Cloud here](https://cube.dev/cloud?utm_source=dev-to&utm_medium=post&utm_campaign=starting-a-new-cube-app-in-cube-cloud) to try it out for yourself.

Until next time, stay curious, and have fun coding. Also, feel free to [leave Cube a ⭐ on GitHub](https://github.com/cube-js/cube.js) if you liked this article. ✌️