Code.org is a non-profit dedicated to computer programming education. Founded by brothers Ali and Hadi Partovi, the organization works to increase the number of computer science programs in U.S. schools and expand participation by women and underrepresented students of color. Code.org offers coding programs and tutorials on its website and advocates for computer science curriculum with federal and local organizations. Code.org launched in January 2013 and is a public 501c3 organization with support from public donations.

In August 2013, Code.org decided to launch Hour of Code — a campaign to introduce students to coding programs and tutorials on the organization’s website — during CSEdWeek, which occurs in December. Prior to Amazon Web Services (AWS), Code.org’s environment was a set of disparate websites running on different technologies. Code.org set an ambitious goal of reaching 10 million students and the non-profit’s engineers had four months to build a platform capable of supporting the campaign.

Code.org needed the ability to handle extreme spikes in traffic as students logged on during CSEdWeek while controlling costs. The organization considered other cloud providers, but ultimately chose AWS because of the flexibility, low cost and complete set of services offered by the AWS Cloud.

Additionally, Code.org would be able to leverage the AWS global infrastructure and multiple regions to plan for redundancy and high availability. “Initially, we planned to launch as a national campaign,” says software engineer, Geoffrey Elliott. “Launching internationally was an afterthought, but because we were building on AWS, it didn’t change our design. We knew that we could launch and scale in another AWS Region.”

Code.org’s environment runs on two stacks on AWS: one for its interactive tutorial programs and another for users interested in learning more about the Hour of Code initiative. Both stacks run in the in US East (No. Virginia) Region and use Amazon RDS Multi-AZ for automatic failover and high availability at the database tier.

Code.org creates its own tutorials using Blockly and other tools to create a graphical, immersive experience for students. The foundation also works with Khan Academy and several other partners to provide dozens of tutorials for the website. Code.org operates the web tutorials on AWS using Ruby on Rails, MySQL on Amazon Relational Database Service (Amazon RDS), Amazon CloudFront to deliver content and Amazon Route 53 as its domain name system (DNS) web service.

“Once you start using services like Amazon Route 53, it’s hard to move away,” says Elliott. “About every 90 days, one of our local servers is assigned a new IP address. Adjusting a DNS setting manually doesn’t sound like a lot of work, but once you don’t have to do it at all, it is a big deal. Amazon Route 53 uses aliases for endpoints instead of actual IP addresses, so DNS updates are mostly automatic. I don’t have the headache of worrying about IP address changes. It’s why I value this feature and others that AWS offers.”

Code.org spent time testing and identifying its web application to identify bottlenecks and improve performance. To optimize operations, engineers partitioned server activities into read operations (when users read a page) and write operations (when users fill out a form). Front-end servers generate and cache a page once and then moves all write operations to the back-end servers responsible for updates to database. Elastic Load Balancing ensures high availability to handle extreme spikes in traffic.

Engineers deployed Varnish cache to hold and accelerate delivery of dynamic web content. Amazon RDS database instances in a Multi-AZ configuration support the database tier. CloudFront delivers content from AWS edge locations to users, allowing for further reduction of load on front-end servers. CloudFront also allows content to be served to global users in the most efficient manner. “By using CloudFront, we were able to scale to handle over 300,000 users concurrently during peak load,” says Elliott.

Amazon Elastic Compute Cloud (Amazon EC2) offers a variety of instance types for different computing needs. After extensive testing, Code.org’s engineers found that Amazon EC2 Compute Optimized instances worked best for their web servers. While web traffic isn’t compute-heavy, those machines generate pages that are CPU-intensive.

“To get the best throughput, you need the fastest processor,” says Elliott. “We use C3 instance types for our front-end machines because of high performance and value for the dollar.” Performance testing indicated that CPU isn’t as critical for Code.org’s cache servers, and the organization uses inexpensive instances that keep the entire cache in RAM.

Running on AWS, Code.org was able to launch the Hour of Code campaign during CSEdWeek as planned. “Our goal was 10 million students and we had 20 million participants,” says Elliott. “Running on the AWS Cloud gave us the elasticity to keep the website running when traffic spiked from zero to 20 million coders during campaign week, and then scale back efficiently. AWS was fantastic.”

Since Hour of Code started, more than 25 million students—half of them female—from over 170 countries have written nearly one billion lines of code on Code.org.

After launch, Code.org realized that it was over-provisioned and the team started taking machines out of production. “Once we understood how AWS scaled, we were able to spin down instances to save on costs. Even though traffic was busy and increasing daily, we were able to take about 50 percent of the machines out of production.” Code.org launched with 21 instances for its front-end web servers during Hour of Code, and since then has scaled back to run on two instances.

AWS architects and AWS Support, Business-level helped Code.org fine-tune its architecture before and during campaign week. Before launch, the organization worked with AWS architects to build redundancy and high availability into the web platform and set up Amazon RDS Multi-AZ across several Availability Zones. The weekend before the site went live, AWS Support engineers started a pre-warming process to ensure that Elastic Load Balancing would be able to handle sudden increases in traffic.

During CSEdWeek, AWS Support engineers provided a solution to get e-mail messages out faster on Amazon Simple Email Service (Amazon SES). Elliott comments, “AWS is so amazing, we got to worry about details like deliverability rate instead of staying online. We spent campaign week focused on taking machines out of production and enjoying the fact that everything worked.”

Using AWS helps Code.org to focus on goals instead of infrastructure. “Our expectation is that the service will just work—and it does,” says Elliot. “Our experience with AWS has been exceptional.”