Vitesse was created to address the scaling issues YouTube faced with MySQL. YouTube was running out of resources and pushing the limits of MySQL, particularly with replicas storing more data than MySQL could handle. Vitesse was designed to handle these scaling issues by enabling horizontal scaling and distribution of load across multiple MySQL nodes.
PlanetScale is a hosted, MySQL-compatible, serverless database platform. It offers features like database branching, zero-downtime migrations, data caching, an API, a CLI, and integrations with other services. Unlike traditional MySQL, PlanetScale uses Vitesse to enable horizontal scaling, making it easier to manage large amounts of data and traffic.
Horizontal scaling is more cost-effective and reliable because adding more machines (nodes) to a cluster distributes the load, improving performance and reliability. Vertical scaling, on the other hand, involves adding more resources to a single machine, which can become expensive and eventually hits a performance ceiling. Horizontal scaling also provides redundancy, ensuring that if one node fails, others can continue to serve requests.
Vitesse is a layer on top of MySQL that acts as a gateway or load balancer. It distributes the load across multiple MySQL nodes, enabling horizontal scaling. Vitesse was originally created to scale YouTube's MySQL databases by breaking up data across multiple nodes and ensuring efficient load distribution.
The main differences between MySQL and Postgres include data types and specific SQL syntax. Postgres supports more data types and has a native UUID type, while MySQL requires using a binary 16 or a raw string for UUIDs. The syntax for pagination also differs, with Postgres using `LIMIT` and MySQL using `TOP`. For most developers, the transition is relatively smooth, with about 95% of knowledge transferring directly.
PlanetScale sets up read-only replicas to handle read operations, while writes are directed to a primary node. This setup optimizes for read-heavy applications, which is common for most web apps. While it is possible to configure nodes for both reads and writes, the complexity and potential consistency issues often outweigh the benefits for most use cases.
Geographic data distribution with PlanetScale allows you to place read replicas closer to your users, reducing latency and improving application performance. For example, if you have a large user base in Europe, you can place a read replica in an AWS region in Europe, ensuring that read operations are faster and more efficient for those users.
Database branching in PlanetScale allows developers to create isolated copies of the database schema for testing and feature development. It works similarly to Git branching, with features like deploy requests for reviewing and merging changes. This ensures that changes can be made and tested without impacting the production database, and deployments can be done with zero downtime.
Data branching in PlanetScale involves restoring the most recent backup of the source branch to a new branch, creating a complete replica of the production database. This feature is useful for testing and development, allowing developers to work with real data in an isolated environment. It helps in accurately simulating production conditions and testing complex changes.
Developers can visit planetscale.com/docs for detailed documentation on features and usage. The PlanetScale blog offers tutorials and in-depth articles, and the YouTube channel provides video tutorials. The hobby plan is free and includes a 5GB database with generous read and write limits, making it ideal for learning and small projects. Users can also reach out via the PlanetScale Twitter account for support and updates.
Lane and Brian talk about scaling databases, particularly MySQL, Vitess, and the PlanetScale platform. Brian is a developer educator at PlanetScale, and he breaks down how you can think about scaling databases for your own projects, or for the companies you work for. PlanetScale is used for cloud MySQL deployments in the new CI/CD course on Boot.dev that just dropped!
Brian on Twitter: https://twitter.com/brianmmdevPlanetScale: https://planetscale.com/