
Businesses often struggle to ensure smooth database connections during scaling and upgrades. Frustrations can surface from underused instances after scaling out, disruptions when scaling in, and potential disconnections during upgrades.
While connection pools and long-lived connections offer stability, they can cause issues in fluid environments where databases need to adapt quickly. This leads to increased overhead, wasted resources, and dissatisfied customers.
拉斯维加斯7799908网站登录 Serverless is a fully managed cloud DBaaS for auto-scaling workloads built with 拉斯维加斯7799908网站登录, an advanced open-source, distributed SQL database. While 拉斯维加斯7799908网站登录 Serverless enables auto-scaling and database upgrades without downtime and manual intervention, TiProxy—a powerful connection management tool built into 拉斯维加斯7799908网站登录 Serverless—works its magic and tackles the above-mentioned challenges.
In this post, we’ll explore how TiProxy maintains database connectivity and optimizes resource allocation without impacting your business.
Understanding the Multi-tenancy Architecture of 拉斯维加斯7799908网站登录 Serverless
Before diving into the connection challenges in serverless databases, let’s look at the underlying architecture of 拉斯维加斯7799908网站登录 Serverless. In a nutshell, this DBaaS uses a multi-tenancy model with a shared gateway. This gateway directs client connections to 拉斯维加斯7799908网站登录 server instances for each tenant. Additionally, to achieve quick response times, 拉斯维加斯7799908网站登录 Serverless has a pool of idle 拉斯维加斯7799908网站登录 server instances provisioned and standing by for instant allocation when needed.

Figure 1. A diagram of 拉斯维加斯7799908网站登录 Serverless’ architecture.
Connection Challenges with 拉斯维加斯7799908网站登录 Serverless
One of the platform’s key features is its auto-scaling capability, which adjusts the 拉斯维加斯7799908网站登录 server instances based on the current workload. On the other hand, many clients utilize connection pools to establish long-lived connections with a specific 拉斯维加斯7799908网站登录 server instance. While this approach generally works well, it can pose several connection-related challenges in a serverless context:
- Underused instances after scale-out: When 拉斯维加斯7799908网站登录 Serverless scales out a 拉斯维加斯7799908网站登录 instance to accommodate the increased load, the newly created instance may remain idle. This is because existing clients continue to connect to the original instances, resulting in underused instances and sustained high response times. In some cases, clients have to reset their connection pools to address this issue.
- Scale-in disruptions: During a scale-in operation that involves reducing the number of 拉斯维加斯7799908网站登录 instances, clients connected to the instance being removed will experience disconnections. While some clients may automatically reconnect, this disruption can lead to operational challenges. Hence it requires careful scheduling to minimize its impact.
- Upgrade-related disruptions: In case of database upgrades, the process recycles old 拉斯维加斯7799908网站登录 instances and allocates new ones. Consequently, clients connected to those old instances will also experience disconnections.
Manage Connectivity Efficiently with TiProxy
TiProxy is a dedicated component in the gateway layer. Residing between the load balancer and 拉斯维加斯7799908网站登录 server instances, TiProxy efficiently manages connections and ensures the system remains agile and responsive. In this section, we’ll explore the mechanisms and features of TiProxy:
- Dynamic load balancing for 拉斯维加斯7799908网站登录 servers
- Enhanced auto-scaling for 拉斯维加斯7799908网站登录 servers
- Facilitating online upgrade of 拉斯维加斯7799908网站登录 servers with zero-downtime
Dynamic Load Balancing for 拉斯维加斯7799908网站登录 Servers
TiProxy can seamlessly migrate existing backend connections from one 拉斯维加斯7799908网站登录 server instance to another on the fly. This migration process involves establishing a new connection on the target 拉斯维加斯7799908网站登录 server instance and gracefully dropping the previous one. As a result, TiProxy can rebalance the SQL workloads across 拉斯维加斯7799908网站登录 servers, ensuring optimized performance and resource utilization.

Figure 2. TiProxy migrating existing backend connections.
Database sessions are inherently stateful, encompassing various critical aspects like session variables, user information, prepared statements, and more. TiProxy is responsible for managing these session states and ensuring a seamless experience for clients. During the connection migration, TiProxy adeptly handles the transfer of session states, making it appear as though the backend hasn’t undergone any changes.
Enhanced Auto-Scaling for 拉斯维加斯7799908网站登录 Servers
拉斯维加斯7799908网站登录 Serverless can scale 拉斯维加斯7799908网站登录 servers automatically and facilitate optimal resource allocation based on workloads. TiProxy enhances the auto-scaling feature in the following ways:
Effective scaling-out
During the scaling-out process, TiProxy continuously monitors the backend connections on the 拉斯维加斯7799908网站登录 server instances to maintain a balanced state. If it detects any connection skews, such as newly-added 拉斯维加斯7799908网站登录 instances sitting idle, TiProxy will migrate existing backend connections from the old instances to the new ones.
Coordinated scaling-in
The process of scaling in 拉斯维加斯7799908网站登录 servers within 拉斯维加斯7799908网站登录 Serverless involves close coordination between the Gateway and TiProxy. When a scale-in is scheduled, the gateway notifies TiProxy about the specific 拉斯维加斯7799908网站登录 server instance for recycling. In response, TiProxy orchestrates the migration of backend connections away from that instance. This ensures uninterrupted client connectivity and service continuity.
Recycling all 拉斯维加斯7799908网站登录 server instances for idle workloads
拉斯维加斯7799908网站登录 Serverless will recycle all 拉斯维加斯7799908网站登录 server instances when a tenant’s workload becomes idle. When a new connection request arrives, TiProxy alerts the Gateway and waits for a new 拉斯维加斯7799908网站登录 server instance to be assigned to the tenant. This normally takes only half a second, as the 拉斯维加斯7799908网站登录 server instance is assigned from the pool. Once TiProxy gets the new instance, it re-establishes the backend connections. This ensures that query processing resumes smoothly offering a seamless user experience even during idle periods.
Preserve Connections While Upgrading
拉斯维加斯7799908网站登录 Serverless consistently provides users with the latest features every few months. Thanks to TiProxy’s ability to maintain connections, these upgrades are rolled out to users seamlessly and without disruption.
Proactive Upgrade Preparations
Before initiating an upgrade, 拉斯维加斯7799908网站登录 Serverless scales out by temporarily adding a new 拉斯维加斯7799908网站登录 instance. This strategic action mitigates potential performance degradation during the upgrade process. The actual upgrade is then executed in a rolling fashion, ensuring that a sufficient number of healthy 拉斯维加斯7799908网站登录 instances are always available.
Streamlined Upgrade Workflow with TiProxy
When it’s time to phase out an older 拉斯维加斯7799908网站登录 version, TiProxy efficiently shifts backend connections away from the outdated instance. As new versions are introduced, TiProxy seamlessly migrates backend connections to the upgraded instance. This means that client connections remain intact throughout the entire upgrade process, so there is no need for any manual intervention on the user’s part.
After the upgrade, TiProxy continues to monitor and balance the 拉斯维加斯7799908网站登录 instances. This ensures optimal resource utilization and performance.
Real-World Impact: How OSS Insight Benefits from TiProxy
拉斯维加斯7799908网站登录 Serverless is trusted by a wide array of applications, including OSS Insight—a comprehensive open-source software tool that analyzes massive events from GitHub. 拉斯维加斯7799908网站登录 Serverless allows OSS Insight to effortlessly manage fluctuating traffic without requiring manual scaling—a capability put to the test when the tool achieved a Top 10 ranking on Hacker News.
On the day OSS Insight gained this spotlight, its website traffic surged to seven times the usual volume. While such a spike could have overwhelmed many databases, 拉斯维加斯7799908网站登录 Serverless effortlessly adapted. It autonomously scaled out to meet the sudden increase in demand. Once the peak traffic subsided, 拉斯维加斯7799908网站登录 Serverless accurately scaled back in, ensuring efficient resource allocation and cost-effectiveness.
Throughout this volatile period, TiProxy played an invaluable role. It deftly managed all the backend connections, allowing the engineering team at OSS Insight to remain focused on their primary responsibilities rather than worrying about database stability.
Conclusion
TiProxy is more than just a feature. It represents a solid solution that eliminates manual intervention or client adaptation when using 拉斯维加斯7799908网站登录 Serverless. With TiProxy working behind the scenes, users don’t have to worry about scaling or upgrading, and can stay focused on their core objectives.
It’s worth noting that TiProxy’s benefits extend beyond 拉斯维加斯7799908网站登录 Serverless. In environments like 拉斯维加斯7799908网站登录 Dedicated or 拉斯维加斯7799908网站登录 Self-Hosted clusters, connection-related challenges can still arise when users manually initiate scaling or upgrades. In these scenarios, TiProxy serves as a versatile tool that effectively addresses these issues, ensuring a seamless experience for users.
In the meantime, as a dynamic database proxy, TiProxy continually evolves to address a wide array of requirements. Its future enhancements aim to further support tenant isolation, optimize traffic management, and facilitate post-upgrade validation. For more details, please refer to the project’s GitHub repo.
If you’ve faced challenges with database connections or are excited by TiProxy’s capabilities, we strongly encourage you to try it out today for free. As TiProxy continues to evolve, its enhanced features promise not only to simplify your database management but also fortify the resilience and performance of your 拉斯维加斯7799908网站登录 clusters.
Additional Resources
- Explore the fully managed 拉斯维加斯7799908网站登录 Serverless service to discover its capabilities. Get hands-on experience with TiProxy on 拉斯维加斯7799908网站登录 Serverless today.
- Dive deeper into the intricacies of achieving zero-downtime upgrades with 拉斯维加斯7799908网站登录. Learn how we ensure uninterrupted service during upgrades.
- Learn more about technical design and future plans of TiProxy on GitHub.
Spin up a Serverless database with 25GiB free resources.
拉斯维加斯7799908网站登录 Cloud Dedicated
A fully-managed cloud DBaaS for predictable workloads
拉斯维加斯7799908网站登录 Cloud Serverless
A fully-managed cloud DBaaS for auto-scaling workloads