Citus swirl

With Citus, PersistIQ Can Focus on Their Application & Forget About Their Database

<500ms
response times for 97% of queries
10X
faster for complex queries

PersistIQ is a sales engagement tool for sales teams. The platform helps salespeople communicate in a personalized way at scale.

“Sales teams use our software to reach out to prospects, stay persistent, and do that across hundreds or thousands of people,” says Cyrus Karbassiyoon, CTO at PersistIQ. “It usually takes several touches before you get a prospect interested. PersistIQ brings marketing automation tools to the individual salesperson and empowers them to communicate consistently at scale.”

PersistIQ’s rapid growth resulted in massive tables and slow queries

PersistIQ is a multi-tenant SaaS application that is growing fast. As a result, as PersistIQ's user base grew, the underlying Heroku Postgres database was outgrowing the resources of a single machine.

“The Heroku team was great and we liked Postgres, but we'd outgrown the configuration we had,” says Karbassiyoon. “We store a lot of email data and event data, so our needs could no longer be met by a single-node database. It was breaking too frequently.”

Customers began experiencing performance issues. “We had a few tables that were getting so large that the indexes didn’t fit in memory,” says Karbassiyoon. “Requests would have to go to disk. Going outside of memory was really slow—several seconds per query. Customers were getting extremely frustrated. We had to find a way to scale our database.”

According to Karbassiyoon, the pain caused by the previous database’s inability to scale was extreme. “I was waking up at all hours of the night trying to make sure the PersistIQ site was running. That time was very stressful. We anticipated the issue, fortunately, but performance became a problem earlier than we expected because we were successful and growing.”

PersistIQ screenshot
Citus Cloud powers PersistIQ’s sales engagement application

PersistIQ began searching for “a Postgres that could scale”

Karbassiyoon began searching for a database sharding solution that would allow his team to avoid rewriting PersistIQ’s application. “We wanted to scale horizontally as fast as possible without thinking about it,” Karbassiyoon says. “I just wanted a Postgres that could scale.”

PersistIQ initially considered trying to build a sharding solution in-house but quickly decided against that strategy. “It didn't seem like spending a lot of time figuring out sharding was the best use of our time,” says Karbassiyoon. “Sharding is not our core business. Sharding wasn’t going to move the needle for our product, and implementing sharding ourselves would have meant diverting a lot of time and energy from our own app, plus ongoing maintenance. We asked ourselves: do we spend time figuring out sharding, or should we spend time building features for our customers?”

Once Karbassiyoon decided to seek an external solution to PersistIQ’s scaling challenges, he briefly considered MongoDB. “We did a lot of reading about MongoDB during our evaluation process, but it just seemed difficult and not the right solution,” he says.

He explored other NoSQL databases as well, but both MongoDB and the other NoSQL databases would force him to give up the relational semantics PersistIQ needed to ensure a good customer experience—things like joins, foreign key constraints, and transactions. “Data consistency is really important for us,” says Karbassiyoon. “For example, if you're sending email, you can't send the same email twice. People aren't happy if you do that.”

Sticking with a relational database instead of switching to a NoSQL database also would allow PersistIQ to avoid re-architecting its application. “We use Ruby on Rails, which is designed for relational databases,” says Karbassiyoon. “To switch to a NoSQL database, we would have had to change our ORM and re-architect our application.”

Finally, Karbassiyoon discovered Citus. “The way Citus shards Postgres seemed like a fit for our app right away,” says Karbassiyoon. “We began our due diligence with the Citus technical team immediately.”

We want to focus on our application and our core business, not on managing our database. Sometimes it's just better to use technology that is battle-tested. Citus already takes care of sharding Postgres for many customers—why should we reinvent the wheel?
Cyrus Karbassiyoon, CTO, PersistIQ

Due diligence validated the decision to work with sharding experts at Citus

PersistIQ’s first step was to talk with the Citus team about its use case. “We asked a lot of technical questions around what could go wrong, what the challenges were, and how well tested Citus was,” says Karbassiyoon. “We came out of those discussions feeling confident that Citus would work for us.”

The diligence process also confirmed Karbassiyoon’s feeling that PersistIQ should work with an expert rather than try to implement sharding themselves at the application layer. “We want to focus on our application and our core business, not on managing our database,” he says. “Sometimes it's just better to use technology that is battle-tested. Citus already does sharding for many customers—so why should we reinvent the wheel?”

Scaling up our single-node Postgres deployment worked fine early on, but we knew it wouldn’t last. Our application grew faster than we anticipated. At one point, we had to email our customers to let them know we were working to fix the latency and performance issues. Now, with Citus, our query response times are less than 500 milliseconds for 97% of our queries.
Cyrus Karbassiyoon, CTO, PersistIQ

PersistIQ’s multi-tenant gem integrated seamlessly with Citus Cloud

The PersistIQ team started testing Citus by trying to get PersistIQ to run locally on Citus, using the Citus open source packages they had downloaded. “We had been using a multi-tenant Ruby gem, which was powered by Rails, and row-based tenancy,” says Karbassiyoon. “The multi-tenant Ruby gem made it easy for our application and ORM to talk to Citus with hardly any modification. We didn’t have to rewrite our app at all.”

After creating a developer account in Citus Cloud, the database as a service that is managed by the Postgres experts at Citus, the PersistIQ team created a test suite to validate that everything was working properly. “We were concerned that people using our application would do something that might produce a query that wouldn’t work. That’s the nightmare scenario,” says Karbassiyoon. “We went back and forth, trying things, finessing, until we were confident that our user experience would be good. These tests were one of the main factors that helped us decide that yes, Citus would be a good technology partner.”

Migration to the Citus Cloud database was easy

Once PersistIQ was satisfied that Citus would meet its needs, Karbassiyoon’s team devised a plan to migrate to the Citus database as a service with minimal downtime. “We took the site offline for maybe half the day,” says Karbassiyoon. “Then we switched over to Citus and everything worked. It's exactly what you want to happen. No problems. It just worked. And we didn’t even have to move our application off of Heroku.”

The Heroku team was great and we liked Heroku Postgres, but we'd outgrown the single-node configuration we had,” says Karbassiyoon. “We store a lot of email data and event data, so our needs could no longer be met by a single-node database. It was breaking too frequently.
Cyrus Karbassiyoon, CTO, PersistIQ

Query response times sped up—from several seconds per query to sub-second responses

PersistIQ began using Citus Cloud in production in early 2017. Since then, PersistIQ has seen massive improvements in its application performance.

“Before Citus, we had to email customers to let them know we were working to fix the latency and performance issues, since their queries were taking several seconds,” says Karbassiyoon.

“Our indexes weren't in memory, so queries were taking way too long with our previous database. In some cases, queries on our previous database would just time out. Requests would start backing up, and the site would go down.”

PersistIQ’s app was restricted by the amount of memory available. “Once we migrated to Citus Cloud and distributed the database, there was a dramatic increase in the amount of memory available. Just like that, our database was infinitely scalable.” says Karbassiyoon.

Today, however, performance is a key selling point for PersistIQ. “Now, with Citus, our query response times are less than 500 milliseconds for 97% of our queries,” says Karbassiyoon.

With Citus Cloud, PersistIQ no longer worries about how to scale their database

Introducing Citus Cloud into its stack has freed PersistIQ’s development team from database management tasks that were distracting them from new feature development. “Working with Citus feels like we have a team of dedicated DBAs that are 100% focused on making sure that our database is up and running,” says Karbassiyoon. “Our internal engineering team doesn't have to worry about how to scale our database. We can focus on our core business. In fact, I haven’t even thought about our database in the last two months!”

Karbassiyoon is happy to have adopted Citus Cloud to scale out Postgres—and is happy that his team no longer has to worry about database performance and scale. He also appreciates the Postgres expertise in the Citus Data team, and his access to their database expertise. “We have a private Slack channel for support,” says Karbassiyoon. “It's definitely useful. When we ask questions, people at Citus get back to us right away. Our relationship with Citus has worked out great.”

PersistIQ + Citus Data Story Highlights

persistiq.com

  • Scaled out Postgres horizontally without any major application rewrites
  • 10X faster response times for complex queries on the Citus database cluster vs. PersistIQ’s previous single-node Postgres deployment. While single-node Postgres worked well for PersistIQ in the beginning, once PersistIQ’s application had grown, PersistIQ started to hit the limits of single-node Postgres
  • Migrated from Heroku Postgres to Citus Cloud easily, with minimal downtime

Scaling up our single-node Postgres deployment worked fine early on, but we knew it wouldn’t last. Our application grew faster than we anticipated. At one point, we had to email our customers to let them know we were working to fix the latency and performance issues. Now, with Citus, our query response times are less than 500 milliseconds for 97% of our queries.

Cyrus Karbassiyoon, CTO, PersistIQ

About PersistIQ

PersistIQ is on a mission to help sales teams work smarter and sell more effectively. Founded in 2014, PersistIQ unifies sales communication and workflow into a single easy-to-use system. By combining the power of automation with the human touch that wins sales, PersistIQ empowers its customers to create stronger, more predictable deal flow.

persistiq.com

Recommended Next Steps