The major advantage for us in using AWS has been in our ability to focus on our applications rather than on our infrastructure.
Shashank Mehta Product Director, Razorpay
  • Razorpay needed a highly reliable and scalable infrastructure to operate e-commerce services continuously
  • The company is running its payment-gateway service on AWS
  • Completed migration to Amazon Asia Pacific South (Mumbai) Region with less than four minutes downtime
  • Reduced latency from 400 milliseconds to about 10 milliseconds
  • Supported 150% increase in traffic with no impact on performance or availability
The demonetization program began on November 8, 2016, just as we were migrating our infrastructure from the United States to Mumbai. The following month was our largest month ever, with traffic increasing by up to 150 percent. Because we had deployed Auto Scaling to scale up our Amazon EC2 instances, we could support the additional traffic with no impact on performance or availability.
Rahul Menon Senior Infrastructure Engineer, Razorpay

Founded in 2015 and headquartered in Bangalore, India, Razorpay provides payment-gateway services used by more than 30,000 merchants. The business accepts and validates Internet payments by credit card, debit card, online banking services, and digital wallets. Razorpay’s primary goal is to help Indian businesses establish an online presence that enables customers to complete financial transactions quickly and reliably.  

When the company launched, Razorpay’s owners and investors knew the business was launching into a payment-gateway market in India that was dominated by other incumbents. However, according to Shashank Mehta, product director at Razorpay, the business could differentiate itself by improving on existing payment-transaction completion rates. These could be as low as 60 percent in some cities in India¾dramatically lower than the 95 percent average transaction-completion rates in the United States. “Forty percent of online transactions in India were failing¾causing a sizable financial loss for the country’s merchants,” says Mehta. Razorpay also recognized an opportunity to help merchants integrate payment-gateways into their technology environments. According to Mehta, this process could sometimes take merchants up to a month to complete and would delay merchants’ access to revenue and growth opportunities.

Razorpay needed an infrastructure that could support the above objectives as well as a predicted rapid increase in demand post launch. The infrastructure also needed to support fluctuations in demand. These changes could occur due to increases in payment transaction volumes during certain times of the day; when market conditions changed; or when the government made far-reaching policy changes. Furthermore, the infrastructure had to deliver the reliability required for Razorpay and its merchants to operate e-commerce services continuously. “These companies could not afford downtime because it would directly affect their revenue and ultimately their reputation among current and prospective customers,” says Mehta. Razorpay also needed to minimize latency to provide performance that enabled merchants to deliver a fast, competitive user experience. “Delivering such an experience is vital in the world of e-commerce where dissatisfied customers can move to a competitor’s website in seconds,” says Mehta.

After conducting a detailed evaluation of the Amazon Web Services (AWS) Cloud and other cloud providers, Razorpay opted to deploy its payment-gateway and associated systems on AWS. “The other providers did not have the reliability we needed at that point, whereas AWS could deliver high availability, rapid scalability, and seamless performance, as well as services that could automate functions such as load balancing, domain name system management, storage, and queueing,” says Mehta. “AWS also complied with the Payment Card Industry Data Security Standard (PCI DSS), ensuring we could accept transactions from branded cards from companies such as Visa, MasterCard, and American Express.”

Razorpay’s in-house team then designed and deployed an infrastructure for the business in the US East (Northern Virginia) Region. The infrastructure included Amazon Elastic Compute Cloud (Amazon EC2) instances running in an Auto Scaling group that automates the process of scaling resources to meet demand, as well as AWS CodeDeploy to automate application deployments to Amazon EC2 instances. Razorpay uses Elastic Load Balancing to distribute application traffic across Amazon EC2 instances to optimize application performance, Amazon ElastiCache to provide a cloud-based in-memory data store and cache, and Amazon Relational Database Service (Amazon RDS) to run a MySQL database of payment-transaction details including payment methods used. The company also uses Amazon Simple Storage Service (Amazon S3) to store static assets, and AWS Lambda to run serverless compute resources.

When AWS decided to launch an Asia Pacific (Mumbai) Region in June 2016, it presented opportunities for Razorpay to reduce latency and fulfill data-sovereignty requirements. The business was planning applications and services that needed to comply with legislation that required sensitive data about Indian merchants and customers to be located within India. The business started to review options for migrating its AWS infrastructure from the US East (Northern Virginia) Region to the Asia Pacific (Mumbai) Region. “We spoke to AWS and their representatives gave us a few options for the data migration,” says Mehta, “The critical nature of our business for merchants meant we had to complete the project with downtime of less than 10 minutes.”   

After considering its options, Razorpay chose to take advantage of the cross-region replication features of the Amazon Aurora relational database engine. “We decided to use Amazon Aurora to set up a slave of our master MySQL database in the US East Region, and since this service supports cross-region replication, we could set up a replica Amazon Aurora in Asia Pacific (Mumbai) Region and seamlessly transfer data across,” says Mehta.

Razorpay set up the replication process the day before the migration was scheduled to ensure a smooth data flow between the regions as required. During the migration process, Razorpay shut down replication and moved its domain name system (DNS) to the Mumbai data center. Rapid DNS propagation helped ensure the process was completed with minimum disruption to merchants.

Razorpay has achieved a range of benefits from using the AWS Cloud and by using Amazon Aurora to migrate to the Asia Pacific South (Mumbai) Region. The business completed the move with less than four minutes of downtime¾well within the requirement of 10 minutes. Razorpay has also been able to retain all customer and merchant information within India to meet its compliance obligations. “If the Asia Pacific South (Mumbai) Region was not available, we would have had to run our application across two data centers and providers, with consequent increases in cost and management resources,” says Mehta.

Razorpay’s move to the Asia Pacific South (Mumbai) Region has also enabled the business to minimize latency to improve payment success rates and the experience for end customers. Latency has fallen from 400 milliseconds when the business’s infrastructure was located in the United States, to about 10 milliseconds. “This is an advantage as we find a correlation between falling latency and the successful completion of payments,” says Mehta. “These success rates have risen by about three percent since we moved to India, realizing an increase in revenue.”

The scalability of AWS proved critical to Razorpay in late 2016, when the Indian government undertook a “demonetization program” in an effort to cripple the nation’s black market. The government voided 500-rupee and 1,000-rupee notes and required the population to redeem them for new 500-rupee and 2000-rupee notes, or deposit them in bank accounts, within a 50-day period. This process prompted many Indian people to take up e-commerce and e-payment services.  

“The demonetization program began on November 8, 2016, just as we were migrating our infrastructure from the United States to Mumbai,” says Rahul Menon, senior infrastructure engineer at Razorpay. “The following month was our largest month ever, with traffic increasing by up to 150 percent. Because we had deployed Auto Scaling to scale up our Amazon EC2 instances, we could support the additional traffic with no impact on performance or availability.” The business is now growing at about 3,000 merchants on a month-on-month basis and is poised to reach 1,000,000 transactions per day.

Using AWS has also enabled Razorpay to minimize the time required to make changes, such as provisioning additional infrastructure resources for test, development, staging, or production. “Depending on the layer we are changing, we can complete an adjustment in 10 to 15 minutes at most,” says Mehta. “We do not have to spend weeks procuring new servers and associated resources to undertake these processes.”

According to Mehta, despite being in the market for only two years, Razorpay has become one of the most preferred payment-gateways in India. “The major advantage for us in using AWS has been in our ability to focus on our applications rather than on our infrastructure,” he says. “We are also able to keep our costs low and our team lean. If we increase our traffic or add more merchants, I do not need to hire another two or three engineers to scale up our infrastructure to support the growth.” Thanks to AWS, Razorpay is now ideally positioned to enter new markets such as Indonesia, Thailand, and Myanmar as well as the Middle East and Africa.