MySQL is one of the world's most popular open source relational databases. One of the reasons for its popularity is the ability to host and manage the database in many ways that conform to a user’s workload requirements. A user can choose to set up the database to be self-managed on-premises, self-managed in virtual machines in the cloud, or use a cloud provider's fully managed offering. This article focuses on the self-managed MySQL option and the fully managed solution, Cloud SQL for MySQL, provided by Google Cloud. The pros and cons of each of the options will be covered.
The self-managed MySQL option means that the user, in most cases a database administrator, is responsible for most of the activities involved in the setup, installation, configuration and maintenance of the database, the operation system (OS), networking, storage, the virtual machine (VM) instance, and the hardware, which hosts the database instance and server. Some of these tasks, like hardware, VM instance, storage, networking, and operating system tasks, can be accomplished more easily by leveraging a cloud service provider like Google Cloud. Regardless of whether a user is self managing a database on premises or self managing in the cloud, they are responsible for some major database management tasks necessary for a smooth running of the system. These tasks are listed below.
The diagram below shows the responsibility of the user when opting for the self-managed setup. While self management on Google Cloud reduces some tasks related to hardware, compute, networking, and storage, the responsibilities for management of the remaining layers of the stack are still with the user. The database administrator and application developer still have to spend sufficient time, energy, and resources managing MySQL.
Cloud SQL is a fully managed database service that offers ease of use for setup configuration, maintenance, management, and administration of MySQL, PostgreSQL and SQL Server databases on Google Cloud. Cloud SQL manages all the aspects of hardware, networking, OS, security, monitoring, maintenance, availability, and scaling of the MySQL database. All these responsibilities are obscured from the users, allowing them to focus on application development and delivering value to their customers.
The diagram below is similar to the diagram above which shows the tasks involved in managing the various layers of the MySQL database, with the only difference being that all tasks that Cloud SQL manages on behalf of the user are illustrated in blue.
Other than managing the many tasks illustrated above, Cloud SQL offers various features and solutions that are not available natively in a self-managed environment. Some major features offered by Cloud SQL are listed below.
Reliability: Backup and recovery are the most important activities in database management. Cloud SQL offers automated backup and on-demand backups, which can be used to restore the database to a point in time in case of corruption, disaster, or unintended data modifications.
Availability: Cloud SQL provides high availability by instantiating multiple servers hosting the database across multiple zones with automated failover capability to provide high availability in case of failure of a VM or a data center. Cloud SQL guarantees availability of greater than 99.95% anywhere in the world.
Apart from the high availability feature, Cloud SQL also offers a 24x7 Site Reliability Engineering (SRE) team that is responsible for ensuring reliability of the Cloud SQL for MySQL database instances on Google Cloud.
Cross region read replicas is another feature that can be used as a disaster recovery mechanism in case of any failures. It allows a user to quickly bring up the impacted database in another site (region) with minimal impact to the business.
Scalability: Cloud SQL offers creation of MySQL read replicas, such as additional read-only instances of MySQL, in the same region or in remote regions allowing the servicing of requests from the replicas as well as primary instance, thereby providing better read performance. Read replicas can also be used for the reporting purposes and can be destroyed after business needs are met.
Cloud SQL enables scale up of resources (CPU, memory, and storage) and scale down of resources on the MySQL instance with very minimal downtime. Whereas, in case of self-managed setup, these complicated activities require significant effort, expertise, and planning.
Security: Cloud SQL for MySQL database servers are located in Google Cloud secured data centers ensuring the highest level of security. Furthermore, Google Cloud offers private connectivity with Virtual Private Cloud and user-controlled network access with firewall protection, which ensures that user database servers are beyond the reach of malicious actors.
Another aspect of security is compliance with security regulations. Cloud SQL is compliant with many recognized regulations like SSAE 16, ISO 27001, PCI DSS, and HIPAA.
Cloud SQL offers the ability to manage users and their access to the database through IAM integration. This integration manages authorization and authentication for users of Google Cloud and provides granular access to specific Google Cloud resources thereby preventing unauthorized access to the database. Furthermore, Cloud SQL makes identity and access control easy by providing predefined roles designed to control access to your Cloud SQL resources.
Another security feature of Cloud SQL is the encryption of data at rest and in transit, ensuring that no unauthorized user will be able to access user data.
Cloud SQL offers a password validation feature for database users, which lets customers define password policy for password complexity, minimum password length, password change interval, and use of username in the password at the instance level. Customers can also define policy for password expiration days, number of failed attempts, and old password change requirements at the individual user level. These features in Cloud SQL provide security compliance best practices and reduce the risk of unauthorized access for the critical data.
Cloud SQL also provides a way to audit actions and operations on the MySQL database using an audit log plugin. Audit log provides insights into who did, what action, on which object, and when. Database auditing lets you track specific user actions in the database, such as table updates, read queries, user privilege grants, and others.
Observability: Cloud SQL offers various monitoring solutions and has a growing list of out of the box metrics, which provide insights into the state of the database. Users can make use of the metrics to create alerts to keep administrators aware of the health of the database.
Cloud SQL also provides features like Query insights and recommenders, allowing users to troubleshoot and identify the performance bottlenecks of a query or workload. These features are hard to replicate in a self-managed MySQL environment.
Integration: Cloud SQL offers easy networking connectivity and integration with other services within Google Cloud like Google Kubernetes Engine, Compute Engine, and Cloud Run which make it easy to develop deeply integrated solutions. Cloud SQL also offers native integration with BigQuery and Looker which can be used for the analytical processing of the data present in Cloud SQL.
Patching: As a managed service, Cloud SQL automatically updates instances to ensure that the underlying hardware and operating system are reliable, performant, secure, and up-to-date. Most of these updates are performed while your Cloud SQL instance is up and running. However, certain system updates may require a brief service interruption, for which the users can define maintenance windows for the upgrade activity.
Version upgrades: Cloud SQL also provides an automated process of upgrading the database (MySQL) version. Users can also upgrade the major version by migrating the data to an instance of a higher version.
Pros
Cons
Pros
Cons
Start building on Google Cloud with $300 in free credits and 20+ always free products.