YouTube Icon

How Retool upgraded our 4 TB main application PostgreSQL database

How Retool upgraded our 4 TB main application PostgreSQL database

Retool's cloud-facilitated item is upheld by a solitary husky 4 TB Postgres information base running in Microsoft's Azure cloud. The previous fall, we relocated this information base from Postgres variant 9.6 to form 13 with negligible vacation.

How could we make it happen? Truth be told, it was anything but a totally straight way from point A to point B. Here, we'll recount the story and offer tips to assist you with a comparative overhaul.

For those of you new to Retool, we're a stage for building interior devices quick. You can utilize an intuitive proofreader to assemble UIs, and effectively attach them to your own information sources, including data sets, APIs, and outsider devices. You can utilize Retool as a cloud-facilitated item (which is upheld by the information base we're discussing here), or you can have it yourself. As the 4 TB data set size proposes, many Retool clients are building numerous applications in the cloud.

The previous fall, we chose to overhaul our principle Postgres information base for a convincing explanation: Postgres 9.6 was arriving at end-of-life on November 11, 2021, which implied it would never again get bug fixes or security refreshes. We would have rather not taken any risks with our clients' information, so we were unable to remain on that variant. It was just straightforward.

Also Read:- Google CEO Pichai Calls For A More Global Internet Amid India’s Data Protection Push

Specialized plan
This overhaul included a couple of undeniable level choices:

What rendition of Postgres would it be a good idea for us to move up to?
What system do we use to do the update?
How would we test the update?
Before we make a plunge, how about we survey our requirements and objectives. There were only a couple.

Complete the redesign before November 11, 2021.
Limit personal time, particularly during Monday-Friday business hours around the world. This was the main thought after the hard cutoff time, in light of the fact that Retool is basic to a significant number of our clients.
Personal time is particularly an element while thinking about working on 4 TB. At this scale, simple things become more earnestly.
We maintained that our upkeep window should be around one hour max.
Amplify how much time this overhaul gets us before we need to redesign once more.
PostgreSQL form 13
We chose to move up to Postgres 13, since it fit all of the above standards, and especially the final remaining one: getting us the most time before the following redesign.

Postgres 13 was the most noteworthy delivered adaptation of Postgres when we started getting ready for the overhaul, with a help window through November 2025. We expect we'll have sharded our information base toward the finish of that help window, and be playing out our next significant adaptation overhauls steadily.

Also Read:- How to connect MySQL database in NodeJS with example?

Postgres 13 additionally accompanies a few highlights not accessible in earlier adaptations. Here is the full rundown, and the following are a couple of we were generally amped up for:

Significant execution upgrades, remembering for equal inquiry execution.
The capacity to add segments with non-invalid defaults securely, which wipes out a typical footgun. In prior Postgres variants, adding a section with a non-invalid default makes Postgres play out a table re-compose while hindering simultaneous peruses and composes — which can prompt vacation.
Parallelized vacuuming of lists. (Retool has a few tables with high compose traffic, and we care very much about vacuuming.)
Redesign technique
Incredible, we'd picked an objective form. Presently, how were we going to arrive?

As a rule, the most straightforward method for updating Postgres information base variants is to do a pg_dump and pg_restore. You bring down your application, trust that all associations will end, then, at that point, bring down the data set. With the information base in a frozen state, you dump its items to plate, then reestablish the items to a new data set server running at the objective Postgres form. Once the reestablish is finished, you point your application at the new information base and bring the application back.

Also Read:- How to use foreach object in NodeJS ?

This update choice was engaging in light of the fact that it was both basic, and totally guarantees that information won't be out-of-sync between the old data set and new data set. Be that as it may, we killed this choice immediately on the grounds that we needed to limit personal time — and doing a dump and reestablish on 4 TB would require vacation in days, not hours or minutes.

We rather chose a system in light of intelligent replication. With this methodology, you run two duplicates of your information base in equal: the essential data set you're overhauling, and an optional "supporter" data set running at the objective Postgres rendition. The essential distributes changes to its tenacious stockpiling (by unraveling its compose ahead log) to the auxiliary data set, permitting the optional data set to imitate the essential's state rapidly. This successfully dispenses with the hold back to reestablish the data set at the objective Postgres adaptation: all things considered, the objective data set is state-of-the-art 100% of the time.

Strikingly, this approach requires significantly less personal time than the "landfill and reestablish" system. Rather than reconstructing the whole information base, we essentially had to stop the application, sit tight for all exchanges at the old v9.6 essential to finish, sit tight for the v13 optional to get up to speed, and afterward point the application at the auxiliary. Rather than days, this could happen inside a couple of moments.

Testing methodology
We keep an organizing climate of our cloud Retool occasion. Our testing methodology was to do numerous trials on this organizing climate, and make and emphasize on an itemized runbook through that interaction.

The trials and runbook served us well. As you'll find in the part beneath, we performed numerous manual strides during the support window. During the last cutover, these means went off to a great extent according to plan in light of the various dress practices we'd had in the earlier weeks, which assisted us with building an exceptionally nitty gritty runbook.

Our super starting oversight was not trying with an agent responsibility in arranging. The organizing data set was less than the creation one, and, surprisingly, however the consistent replication technique ought to have empowered us to deal with the bigger creation responsibility, we missed subtleties that prompted a blackout for Retool's cloud administration. We'll frame those subtleties in the part underneath, yet this is the greatest example we desire to convey: the significance of testing with a delegate responsibility.

Also Read:- A Beginner’s Guide to JavaScript’s Prototype

Plan practically speaking: specialized subtleties

Carrying out coherent replication
We wound up utilizing Warp. Remarkably, Azure's Single Server Postgres item doesn't uphold the pglogical Postgres expansion, which our exploration persuaded us to think is the best-upheld choice for sensible replication on Postgres renditions before adaptation 10.

One early diversion we took was evaluating Azure's Database Migration Service (DMS). In the engine, DMS first takes a preview of the source data set and afterward reestablishes it into the objective information base server. When the underlying dump and reestablish finishes, DMS turns on consistent translating, a Postgres highlight that streams steady data set changes to outside supporters.

Notwithstanding, on our 4 TB creation data set, the underlying dump and reestablish never finished: DMS experienced a blunder however neglected to report the mistake to us. In the mean time, regardless of gaining no positive progress, DMS held exchanges open at our 9.6 essential. These long-running exchanges thusly hindered Postgres' autovacuum work, as the vacuum processes can't tidy up dead tuples made after a long-running exchange starts. As dead tuples stacked up, the 9.6 essential's exhibition started to endure. This prompted the blackout we referred to above. (We have since added observing to monitor Postgres' unvacuumed tuple count, permitting us to distinguish hazardous situations proactively.)

Twist works much the same way to DMS yet presents undeniably more design choices. Specifically, Warp upholds equal handling to speed up the underlying dump and reestablish.

We needed to do a cycle of finagling to persuade Warp to handling our data set. Twist anticipates that all tables should have a solitary section essential key, so we needed to change over compound essential keys into remarkable requirements and add scalar essential keys. In any case, Warp was extremely direct to utilize.

Also Read:- PHP Interview Questions And Answers for Experienced

Skipping replication of enormous tables
We further upgraded our methodology by having Warp skirt two especially gigantic tables that ruled the landfill and reestablish runtime. We did this in light of the fact that pg_dump can't work in equal on a solitary table, so the biggest table will decide the briefest conceivable relocation time.

To deal with the two gigantic tables we avoided in Warp, we composed a Python content to mass exchange information from the old data set waiter to the new. The bigger 2 TB table, an add just table of review occasions in the application, was not difficult to move: we held on until after the cutover to relocate the items, as the Retool item works fine and dandy regardless of whether that table is unfilled. We likewise decided to move exceptionally old review occasions to a reinforcement stockpiling arrangement, to eliminate the table size.

The other table, a many gigabytes attach just log of all alters to all Retool applications called page_saves, was trickier. This table fills in as the wellspring of truth for all Retool applications, so it should have been modern the second we returned from upkeep. To settle this, we moved the majority of its items in the days paving the way to our support window, and relocated the rest of the actual window. Albeit this worked, we note that it added extra gamble, since we currently had more work to finish during the restricted support window.

Making a runbook
These were, at a significant level, the means in our runbook during the support window:

Stop the Retool administration and let generally exceptional data set exchanges commit.
Hang tight for the supporter Postgres 13 information base to get up to speed with legitimate deciphering.
In equal, duplicate over the leftover page_saves columns.
When all information is in the Postgres 13 server, empower essential key imperative authorization. (Twist requires these imperatives to be handicapped).
Empower triggers (Warp expects triggers to be incapacitated.)

Also Read:- How Retool upgraded our 4 TB main application PostgreSQL database

Reset all arrangement values, so successive number essential key assignment would work once the application returned on the web.
Gradually bring back the Retool administration, pointing at th

Author Biography.


CrowdforThink is the leading Indian media platform, known for its end-to-end coverage of the Indian startups through news, reports, technology and inspiring stories of startup founders, entrepreneurs, investors, influencers and analysis of the startup eco-system, mobile app developers and more dedicated to promote the startup ecosystem.

Join Our Newsletter.

Subscribe to CrowdforThink newsletter to get daily update directly deliver into your inbox.

CrowdforGeeks is where lifelong learners come to learn the skills they need, to land the jobs they want, to build the lives they deserve.


CrowdforThink is a leading Indian media and information platform, known for its end-to-end coverage of the Indian startup ecosystem.


Our mission is "Har Koi Dekhe Video, Har Ghar Dekhe Video, Ghar Ghar Dekhe Video" so we Provide videos related to Tutorials, Travel, Technology, Wedding, Cooking, Dance, Festivals, Celebration.

Apna Video Wala

News & Blogs


What Is Biometric technology? - Definition and ...

Facial recognition is a process of identifying and confirming a person’s identity using the...

Top Authors

Lamia Rochdi is the Marketing Manager at Bell Flavors & Fragrances EMEA. A successful family-...

Lamia Rochdi

I’m Mertin Wilson a technician in a camera company and certified expert of different P...

Mertin Wilson

Zakariya has recently joined the PakWheels team as a Content Marketing Executive, shortly after g...

Zakariya Usman

Pankaj Singh is a Senior Digital Marketing Consultant with more than 2 years of experience in SEO...

Pankaj Singh

Our Client Says

WhatsApp Chat with Our Support Team