Scaling Internal MySQL for PAS

Page last updated:

Warning: Pivotal Cloud Foundry (PCF) v2.4 is no longer supported because it has reached the End of General Support (EOGS) phase as defined by the Support Lifecycle Policy. To stay up to date with the latest software and security updates, upgrade to a supported version.

This topic describes a procedure for scaling down the internal MySQL databases used by Pivotal Application Service (PAS) system components. It also provides example sizing data from two environments that have significant load on their MySQL clusters.

For additional resources about scaling Internal MySQL, see the following documentation:

Note: The procedures do not apply to databases configured as external in the PAS tile Databases pane.

PAS components that use system databases include the Cloud Controller, Diego brain, Gorouter, and the User Authorization and Authentication (UAA) server. See Cloud Foundry Components.

Scale Down Your MySQL Cluster

This procedure explains how to safely scale your MySQL cluster down to a single node. If you are already running the MySQL cluster with a single node, you do not need to perform these steps.

By default, internal MySQL deploys as a single node. To take advantage of the high availability features of MySQL, you may have scaled the configuration up to three or more server nodes.

Check the Health of Your Cluster

Before scaling down your MySQL cluster, perform the following actions to ensure the cluster is healthy.

  1. Use the Cloud Foundry Command Line Interface (cf CLI) to target the API endpoint of your Pivotal Cloud Foundry (PCF) deployment:

    $ cf api api.YOUR-SYSTEM-DOMAIN
    Setting api endpoint to api.YOUR-SYSTEM-DOMAIN...

    API endpoint: https://api.YOUR-SYSTEM-DOMAIN... (API version: 2.54.0) Not logged in. Use 'cf login' to log in.

  2. Log in with your User Account and Authentication (UAA) Administrator user credentials. Obtain these credentials by clicking the Credentials tab of the Pivotal Application Service (PAS) tile, locating the Admin Credentials entry in the UAA section, and clicking Link to Credential.

    $ cf login -u admin
    API endpoint: https://api.YOUR-SYSTEM-DOMAIN

    Password> Authenticating... OK

  3. Create a test organization to verify the database across all nodes:

    $ cf create-org data-integrity-test-organization
    Creating org data-integrity-test-organization as admin...

    Assigning role OrgManager to user admin in org data-integrity-test-organization ... OK

    TIP: Use 'cf target -o data-integrity-test-organization' to target new org

  4. Obtain the IP addresses of your MySQL server by performing the following steps:

    1. From the PCF Installation Dashboard, click the Pivotal Application Service tile.
    2. Click the Status tab.
    3. Record the IP addresses for all instances of the MySQL Server job.
  5. Retrieve Cloud Controller database credentials from CredHub using the Ops Manager API:

    1. Perform the procedures in the Using the Ops Manager API topic to authenticate and access the Ops Manager API.
    2. Use the GET /api/v0/deployed/products endpoint to retrieve a list of deployed products, replacing UAA-ACCESS-TOKEN with the access token recorded in the previous step:
      $ curl "https://OPS-MAN-FQDN/api/v0/deployed/products" \
      -X GET \
      -H "Authorization: Bearer UAA-ACCESS-TOKEN"
    3. In the response to the above request, locate the product with an installation_name starting with cf- and copy its guid.
    4. Run the following curl command, replacing PRODUCT-GUID with the value of guid from the previous step:
      $ curl "https://OPS-MAN-FQDN/api/v0/deployed/products/PRODUCT-GUID/variables?name=cc-db-credentials" \
      -X GET \
      -H "Authorization: Bearer UAA-ACCESS-TOKEN"
    5. Record the Cloud Controller database username and password from the response to the above request.
  6. SSH into the Ops Manager VM. Because the procedures vary by IaaS, review the SSH into Ops Manager section of the Advanced Troubleshooting with the BOSH CLI topic for specific instructions.

  7. For each of the MySQL server IP addresses recorded above, perform the following steps from the Ops Manager VM:

    1. Query the new organization with the following command, replacing YOUR-IP with the IP address of the MySQL server and YOUR-IDENTITY with the identity value of the CCDB credentials obtained above:
      $ mysql -h YOUR-IP -u YOUR-IDENTITY -D ccdb -p -e "select created_at, name from organizations where name = 'data-integrity-test-organization'"
    2. When prompted, provide the password value of the CCDB credentials obtained above.
    3. Examine the output of the mysql command and verify the created_at date is recent.
      | created_at          | name                             |
      | 2016-05-28 01:11:42 | data-integrity-test-organization |
  8. If each MySQL server instance does not return the same created_at result, contact Pivotal Support before proceeding further or making any changes to your deployment. If each MySQL server instance does return the same result, then you can safely proceed to scaling down your cluster to a single node by performing the steps in the following section.

Set Server Instance Count to 1

  1. From the PCF Installation Dashboard, click the Pivotal Application Service tile.

  2. Select Resource Config.

  3. Use the dropdown to change the Instances count for MySQL Server to 1.

  4. Click Save, then Review Pending Changes and Apply Changes to apply the changes.

  5. Delete your test organization with the following cf CLI command:

    $ cf delete-org data-integrity-test-organization

MySQL Cluster Sizing Examples

This topic describes two sizing examples for internal MySQL in PAS.

Use this data as guidance to ensure your MySQL Clusters are scaled to handle the number of app instances running on your deployment.

Example 1: Pivotal Web Services Production Environment

The information in this section comes from the Pivotal-managed Cloud Foundry deployment, Pivotal Web Services (PWS).

Note: This deployment differs from most PCF deployments in that the MySQL database is used for Diego, but not the Cloud Controller. This means that while there are a large number of queries per second, most of them are reading data, and the number of writes is not realistically reflected.

  • App Instances: ~23,000
  • Average SQL Queries Per Minute: ~308,000
  • Average IOPS: 220
  • Storage Volume Usage: 80%

VM Sizing

The following table displays MySQL VM settings for this environment.

Setting Value
VM Type c4.2xlarge
Storage Volume Type io1
Storage Volume Size 98GB
Storage Volume IOPS 2000

Example 2: Cloud Foundry Diego Test Environment

The information in this section comes from an environment used by the Diego to test the MySQL cluster with a high load similar to one generated large deployment.

  • App Instances: 250,000
  • Average SQL Queries Per Minute: ~5,100,000
  • Average IOPS:
    • Reads: 3.63
    • Writes: 363.98

VM Sizing

The following table displays MySQL VM settings for this environment.

Setting Value
VM Type n1-standard-16
Storage Volume Type pd-ssd
Storage Volume Size 1TB