If you want to learn more about Citus on Microsoft Azure, read this post about Hyperscale (Citus) on Azure Database for PostgreSQL.
PushOwl Uses Citus Cloud to Scale Out Postgres & Speed Up Analytics Queries
PushOwl seeks to help Shopify e-commerce sites capture lost sales by re-engaging visitors through automated web push notifications. With PushOwl, site owners can send notifications to site visitors to remind them of their abandoned shopping carts, and inform them when items come back in stock, orders are shipped, or prices are dropped.
“We have more than 8,500 e-commerce stores that we’re serving right now, up from 3,000 in just one month. We have a broad variety of customers, like a few stores that are just getting started, to stores that do more than $100 million in sales, and we handle the entire push notification infrastructure for them,” says PushOwl Founder Shashank Kumar.
We expected a database migration to be a huge code change, requiring a lot of rewrites. But Citus has a Django multi-tenant library, which minimized the application refactoring we had to do to migrate our application. Except for rewriting a few lines of our app, we ended up using pretty much the same code.Shashank Kumar, Founder, PushOwl
Queries on PushOwl’s customer-facing analytics dashboard were taking too long, up to 8 seconds
PushOwl’s effectiveness comes from a powerful, real-time analytics dashboard that gives site owners valuable insight into what kind of notifications perform best. In addition to impressions and clicks, site owners can see how much revenue is associated with specific notifications, and with PushOwl’s interactive graphs, site owners can look at the same data from different angles, to make data-driven business decisions.
Unfortunately, problems arose when the real-time dashboard was no longer delivering queries in real time. “Our systems were getting very slow. Our queries were taking a long time—up to eight seconds—in a real-time dashboard, that’s a really long time. And the bottleneck was in our previous database. It was a very big pain point for us. We were serving around 3,000 customers at that point, and that lag in response time was killing us,” says Kumar.
At the time, PushOwl was running a single-node Postgres database on Heroku. The only way Kumar could come close to delivering the right user experience was to add very expensive RAM to the single-node database. Adding more RAM would have quickly limited future scalability.
Kumar’s first thought was to migrate to a different database. “We checked out AWS Aurora, MongoDB, and Cassandra. But most of the options we were considering required re-architecting our systems. And when I talked to startups that were already handling a lot of volume, everybody had a different opinion.”
A Google search for advice on speeding up a Postgres database lead Kumar to a blog post by one of Citus Data’s engineers. After exchanging a couple emails and an introductory phone call, Kumar decided to evaluate Citus Cloud, a fully-managed database as a service.
“Since we were already using Postgres, Citus looked like it might be a good solution for us. We ran a few experiments and then decided to go with Citus,” says Kumar. “The Citus Cloud database is multi-tenant and scales horizontally. We had a multi-tenant requirement, so the Citus approach to sharding by tenant resonated with us.”
Smooth migration from Heroku Postgres to Citus Cloud, thanks to Django multi-tenant library
Kumar thought the migration from Heroku Postgres to Citus Cloud would require considerable refactoring of his Django application. “We expected a database migration to be a huge code change, requiring a lot of rewrites. But Citus has a Django multi-tenant library, which minimized the application refactoring we had to do to migrate our application, ” says Kumar. “Except for rewriting a few lines, we ended up using pretty much the same code.”
The Citus Data team was also there to ensure that the migration went smoothly. “One of the engineers did pair programming with us and got us kick-started. He even helped us with code reviews,” says Kumar.
“I really appreciate the support we got from the Citus team, especially during the actual cutover. The team was online every minute, which gave us a lot of trust that when we move the site, we’ll have really awesome customer support to back us,” says Kumar.
This level of support was a contrast to Kumar’s experience with Heroku. “We’d send an email and then have to wait, sometimes until the next day, for a response. We’d respond to that email, and then have to wait again for another response. That becomes tough when you’re scaling an app, and you have to answer to more than 8,500 customers. So support is also a very critical factor for us,” says Kumar.
With Citus, we don’t have to worry about our infrastructure. That’s one of the main reasons I’m on Citus. We don’t have to think about DevOps anymore. We’re automatically and seamlessly scaling in the cloud, and we’re now managing more than 8,500 ecommerce stores. Probably more by the time this goes to press.Shashank Kumar, Founder, PushOwl
With Citus, 95th percentile query response times have been reduced to 30 to 40 milliseconds
The entire migration took about a month, but could’ve been completed even sooner, Kumar said, if not for some other PushOwl projects that were unrelated to Citus.
Once the migration to Citus Cloud was completed, the PushOwl team saw an immediate improvement in performance. PushOwl’s response times for the most complex queries decreased from 8 seconds to 200 milliseconds, a 40X improvement. And, the app’s 95th percentile response time decreased significantly after adopting Citus, down to 30-40 milliseconds.
Today, PushOwl’s database receives 60 requests per second, compared to 25-30 requests on Heroku PostgreSQL. In addition, push notifications have increased from 6.5 million to 50+ million a month. Even with this growth, performance improved significantly.
Kumar attributes part of PushOwl’s success to the sharding capabilities of Citus. “We have a small number of customers that consume a lot of resources, and when they do, they start impacting other customers. One of the features I really love about Citus is that when that happens, you can dedicate a shard to each customer with the tenant isolation feature,” says Kumar. “And because the default sharding in Citus Cloud works so well out of the box, we haven’t even needed to use the tenant isolation feature.”
The Citus database empowers DevOps team to run lean
Moving to Citus Cloud also eliminated the time spent managing a database—a benefit for any sized team, but especially for a small start-up like PushOwl.
“With Citus, we don’t have to worry about our infrastructure. That’s one of the main reasons I’m on Citus. We don’t have to think about DevOps anymore. We’re automatically and seamlessly scaling in the cloud, and we’re now managing more than 8,500 ecommerce stores.” Kumar added, “Probably more by the time this goes to press.”
Prior to migrating to the cloud database, Kumar said he considered adding a DevOps engineer to the team. But with Citus Cloud, Kumar has been able to put off that hire. “Citus has saved me time, because I didn’t have to spend a few months hunting and hiring a DevOps engineer, migrating to a new database, managing and monitoring a database, and things like that. Real, time-consuming work.”
Instead, Kumar and his team have been able to focus on developing features and innovations to PushOwl that help their customers, rather than working on database infrastructure. “Because Citus Cloud is a fully-managed database as a service in the cloud, we’re working on our business logic, not our servers.”
The fact that Citus is open source gives PushOwl peace of mind
“Since Citus is open source, we avoid lock-in, and we know that Citus will continuously evolve because there’s a whole community behind it, not just the people at Citus Data,” he says. “That was really important when we were choosing infrastructure for the long run.”
The vibrant open source community also ensures Kumar that he can get help with the PostgreSQL database when he needs it. “The open source community becomes really valuable when you are in trouble or need help. I’ve already found a lot of helpful information from the Citus-public Slack channel,” he says.
Because Citus Cloud is a fully-managed database as a service in the cloud, we’re working on our business logic, not our servers.Shashank Kumar, Founder, PushOwl
PushOwl is now able to add 50 to 100 new customers each day
For Kumar, the move to Citus Cloud took place just in time. “It was clear from our performance issues on Heroku that we weren’t going to be able to scale to handle the growth in our customer base. It was right in front of our face that the company wouldn’t survive with a single-node Postgres database. Now, on Citus Cloud, we are able to add 50 to 100 customers per day. We prevented a lot of problems by doing the migration at the right time,” he says.
Kumar has been encouraging other companies who are planning to grow and scale to choose Citus from the very start. While starting on single-node Postgres may be a tempting alternative, companies can avoid a migration step and realize the benefits of a fully-managed database, particularly when resources are tight. “If I built another app, that’s what I’d do—I’d choose Citus Cloud from the start.”
Shashank Kumar, Founder, PushOwl
We expected a database migration to be a huge code change, requiring a lot of rewrites. But Citus has a Django multi-tenant library, which minimized the application refactoring we had to do to migrate our application. Except for rewriting a few lines of our app, we ended up using pretty much the same code.
PushOwl helps Shopify e-commerce sites re-engage visitors even after they leave the site. As the #1 push notification app on Spotify, PushOwl enables site owners to send automatic notifications for abandoned shopping carts, back-in-stock updates, and product recommendations. PushOwl’s real-time analytics dashboard enables site owners to perfect their messaging and make better decisions with data.