|
| 1 | +get-the-cluster-connection-string--- |
| 2 | +title: Estimate Serverless Usage with MovR |
| 3 | +summary: Run the MovR sample application to estimate RU usage in CockroachDB Serverless. |
| 4 | +toc: true |
| 5 | +referral_id: docs_serverless_movr |
| 6 | +docs_area: get_started |
| 7 | +--- |
| 8 | + |
| 9 | +This tutorial shows you how to initialize and run the MovR workload on a {{ site.data.products.serverless }} cluster, then use the Request Unit consumption data to estimate a sufficient budget for the MovR workload. |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +MovR is a fictional company that offers users a platform for sharing vehicles, like scooters, bicycles, and skateboards, in select cities across the United States and Europe. The MovR team wants to use {{ site.data.products.serverless }} to run their high-growth, variable workload. They decide to test out a sample workload to see how it will perform and how much it will cost to run. |
| 14 | + |
| 15 | +## Before you begin |
| 16 | + |
| 17 | +- Make sure you have already [installed CockroachDB](../{{site.versions["stable"]}}/install-cockroachdb.html). |
| 18 | +- [Create a {{ site.data.products.serverless }} cluster](quickstart.html). |
| 19 | + |
| 20 | +## Step 1. Get the cluster connection string |
| 21 | + |
| 22 | +1. On the cluster's **Overview** page, click **Connect**. |
| 23 | +1. Select **General connection string** from the **Select option** dropdown. |
| 24 | +1. Open the **General connection string** section, then copy the connection string provided and save it in a secure location. |
| 25 | + |
| 26 | +## Step 2. Create the `movr` database |
| 27 | + |
| 28 | +1. Connect to the SQL shell using the connection string you copied in [Step 1](#step-1-get-the-cluster-connection-string): |
| 29 | + |
| 30 | + {% include copy-clipboard.html %} |
| 31 | + ~~~ shell |
| 32 | + cockroach sql --url \ |
| 33 | + 'postgresql://<username>:<password>@serverless-host>:26257/defaultdb?sslmode=verify-full&options=--cluster%3D<routing-id>' |
| 34 | + ~~~ |
| 35 | + |
| 36 | + Where: |
| 37 | + - `<username>` is the SQL user. By default, this is your {{ site.data.products.db }} account username. |
| 38 | + - `<password>` is the password for the SQL user. The password will be shown only once in the **Connect to cluster** dialog after creating the cluster. |
| 39 | + - `<serverless-host>` is the hostname of the {{ site.data.products.serverless }} cluster. |
| 40 | + - `<routing-id>` identifies your tenant cluster on a [multi-tenant host](https://www.cockroachlabs.com/docs/cockroachcloud/architecture.html#architecture). For example, `funny-skunk-123`. |
| 41 | + |
| 42 | +1. In the SQL shell, create the `movr` database: |
| 43 | + |
| 44 | + {% include copy-clipboard.html %} |
| 45 | + ~~~ shell |
| 46 | + CREATE DATABASE movr; |
| 47 | + ~~~ |
| 48 | + |
| 49 | +1. Exit the SQL shell: |
| 50 | + |
| 51 | + {% include copy-clipboard.html %} |
| 52 | + ~~~ shell |
| 53 | + quit |
| 54 | + ~~~ |
| 55 | + |
| 56 | +1. Return to the **Connect to cluster** dialog from [Step 1](#step-1-set-up-your-cluster-connection) and select `movr` from the **Database** dropdown. |
| 57 | + |
| 58 | +1. Copy the new **General connection string**. |
| 59 | + |
| 60 | +## Step 3. Load the `movr` workload |
| 61 | + |
| 62 | +Load the `movr` dataset using the new connection string: |
| 63 | + |
| 64 | + {% include copy-clipboard.html %} |
| 65 | + ~~~ shell |
| 66 | + cockroach workload init movr \ |
| 67 | + 'postgresql://<username>:<password>@serverless-host>:26257/movr?sslmode=verify-full&options=--cluster%3D<routing-id>' |
| 68 | + ~~~ |
| 69 | + |
| 70 | +## Step 4. Run the workload |
| 71 | + |
| 72 | +Run the `movr` workload for 1 minute using the same SQL connection string as before: |
| 73 | + |
| 74 | + {% include copy-clipboard.html %} |
| 75 | + ~~~ shell |
| 76 | + cockroach workload run movr \ |
| 77 | + --duration=1m \ |
| 78 | + 'postgresql://<username>:<password>@serverless-host>:26257/movr?sslmode=verify-full&options=--cluster%3D<routing-id>' |
| 79 | + ~~~ |
| 80 | + |
| 81 | + You'll see per-operation statistics print to standard output every second: |
| 82 | +
|
| 83 | + ~~~ |
| 84 | + _elapsed___errors__ops/sec(inst)___ops/sec(cum)__p50(ms)__p95(ms)__p99(ms)_pMax(ms) |
| 85 | + 1.0s 0 31.9 32.0 0.5 0.6 1.4 1.4 addUser |
| 86 | + 1.0s 0 6.0 6.0 1.2 1.4 1.4 1.4 addVehicle |
| 87 | + 1.0s 0 10.0 10.0 2.2 6.3 6.3 6.3 applyPromoCode |
| 88 | + 1.0s 0 2.0 2.0 0.5 0.6 0.6 0.6 createPromoCode |
| 89 | + 1.0s 0 9.0 9.0 0.9 1.6 1.6 1.6 endRide |
| 90 | + 1.0s 0 1407.5 1407.8 0.3 0.5 0.7 4.1 readVehicles |
| 91 | + 1.0s 0 27.0 27.0 2.1 3.1 4.7 4.7 startRide |
| 92 | + 1.0s 0 86.8 86.9 4.7 8.4 11.5 15.2 updateActiveRides |
| 93 | + 2.0s 0 26.0 29.0 0.5 1.1 1.4 1.4 addUser |
| 94 | + 2.0s 0 8.0 7.0 1.2 2.8 2.8 2.8 addVehicle |
| 95 | + 2.0s 0 2.0 6.0 2.6 2.8 2.8 2.8 applyPromoCode |
| 96 | + 2.0s 0 0.0 1.0 0.0 0.0 0.0 0.0 createPromoCode |
| 97 | + 2.0s 0 6.0 7.5 0.8 1.7 1.7 1.7 endRide |
| 98 | + 2.0s 0 1450.4 1429.1 0.3 0.6 0.9 2.6 readVehicles |
| 99 | + 2.0s 0 17.0 22.0 2.1 3.3 5.5 5.5 startRide |
| 100 | + 2.0s 0 59.0 72.9 6.3 11.5 11.5 14.2 updateActiveRides |
| 101 | + ... |
| 102 | + ~~~ |
| 103 | +
|
| 104 | + After the specified duration (1 minute in this case), the workload will stop and you'll see totals printed to standard output: |
| 105 | + |
| 106 | + ~~~ |
| 107 | + _elapsed___errors_____ops(total)___ops/sec(cum)__avg(ms)__p50(ms)__p95(ms)__p99(ms)_pMax(ms)__result |
| 108 | + 60.0s 0 85297 1421.6 0.7 0.3 2.6 7.1 30.4 |
| 109 | + ~~~ |
| 110 | + |
| 111 | +## Step 5. Calculate your budget |
| 112 | + |
| 113 | +1. In the {{ site.data.products.db }} Console, close the **Connect to cluster** dialog to return to your cluster's [**Overview** page](cluster-overview-page.html). |
| 114 | +
|
| 115 | +1. In the **Usage this month** section, note the number of RUs your cluster used. You can also see the **Request Units** graph for a breakdown of how many RUs per second you were using over the last minute. |
| 116 | +
|
| 117 | +1. Multiply your usage over one minute by the number of minutes in a month (43800) to estimate how many RUs the workload would use in a month. For example, if you used 1800 RUs: 1800 RUs/min * 43800 min = 78,840,000 RUs. |
| 118 | +
|
| 119 | +1. Calculate your budget. The workload is estimated to use about 79 million RUs per month, and you are given up to 250M free RUs per month, so the free {{ site.data.products.serverless }} offering should be sufficient for your usage. |
| 120 | +
|
| 121 | +## Next steps |
| 122 | +
|
| 123 | +The MovR team can monitor their usage in the {{ site.data.products.db }} Console, and they will receive email alerts when the cluster approaches 50%, 75%, and 100% of its spend limit. If their workload grows and they reach the limits of the {{ site.data.products.serverless }} free offering, they can then set a spend limit. |
| 124 | +
|
| 125 | +To estimate an actual budget for your cluster, you should run your real workload and gather usage data. You can always [edit your spend limit](serverless-cluster-management.html) if your initial estimate turns out to be inaccurate. |
| 126 | +
|
| 127 | +## See also |
| 128 | +
|
| 129 | +- [Serverless Performance Benchmarking](serverless-benchmarking.html) |
| 130 | +- [Manage a CockroachDB Serverless Cluster](serverless-cluster-management.html) |
| 131 | +- [The MovR Example Application](../stable/movr.html) |
| 132 | +- [Example Apps](../stable/example-apps.html) |
0 commit comments