Wednesday, October 31, 2012

Teaching Thousands of Students to Program on Udacity with App Engine, Part Two

Cross-posted with the Google App Engine blog:

This post is part two of a two-part series on how Udacity is using App Engine to teach thousands of students how to program online.

Today’s guest blogger is Chris Chew, senior software engineer at Udacity, which offers free online courses in programming and other subjects.  Chris shares how Udacity itself is built using App Engine.

Steve Huffman blogged yesterday about how App Engine enables the project-based learning that makes his web development course so powerful.  People are often surprised to learn that Udacity itself is built on App Engine.

The choice to use App Engine originally came from Mike Sokolsky, our CTO and cofounder, after his experience keeping the original version of our extremely popular AI course running on a series of virtual machines.  Mike found App Engine’s operational simplicity extremely compelling after weeks of endlessly spinning up additional servers and administering MySQL replication in order to meet the crazy scale patterns we experience.

Close to a year later, with ten months of live traffic on App Engine, we continue to be satisfied customers.  While there are a few things we do outside App Engine, our choice to continue using App Engine for our core application is clear:  We prefer to spend our time figuring out how to scale personalized education, not memcached.  App Engine’s infrastructure is better than what we could build ourselves, and it frees us to focus on behavior rather than operations.

How Udacity Uses App Engine

The App Engine features we use most include a pretty broad swath of the platform:
A high-level representation of our “stack” looks something like this:

Trails and Trove are two libraries developed in-house mainly by Piotr Kaminski.  Trails supplies very clean semantics for creating families of RESTful endpoints on top of a webapp2.RequestHandler with automagic marshalling.  Trove is a wrapper around NDB that adds common property types (e.g. efficient dereferencing of key properties), yet another layer of caching for entities with relations (both in-process and memcache), and an event “watcher” framework for reliably triggering out-of-band processing when data changes.

Something notable that is not represented in the drawing above is a specific set of monkey patches from Trove we apply to NDB to create better hooks similar to the existing pre/post-put/delete hooks.  These custom hooks power a “watcher” abstraction that provides targeted pieces of code the opportunity to react to changes in the data layer.  Execution of each watcher is deferred and runs outside the scope of the request so as to not increase response times.


During our first year of scaling on App Engine we learned its performance is a complex thing to understand.  Response time is a function of several factors both inside and outside our control.  App Engine’s ability to “scale-out” is undeniable, but we have observed high variance in response times for a given request, even during periods with low load on the system.  As a consequence we have learned to do a number of things to minimize the impact of latency variance:
  • Converting usage of the old datastore API to the new NDB API
  • Using NDB.tasklet coroutines as much as possible to enable parallelism during blocking RPC operations
  • Not indexing fields by default and adding an index only when we need it for a query
  • Carefully avoiding index hotspots by indexing fields with predictable values only when necessary (i.e. auto-now DateTime and enumerated “choices” String properties).
  • Materializing data views very aggressively so we can limit each request to the fewest datastore queries possible
This last point is obvious in the sense that naturally you get faster responses when you do less work.  But we have taken pre-materializing views to an extreme level by denormalizing several aspects of our domain into read-optimized records.  For example, the read-optimized version of a user’s profile record might contain standard profile information, plus privacy configuration, course enrollment information, course progress, and permissions -- all things a data modeler would normally want to store separately.  We pile it together into the equivalent of a materialized view so we can fetch it all in one query.


App Engine is an amazingly complete and reliable platform that works astonishingly well for a huge number of use cases.  It is very apparent the services and APIs have been designed by people who know how to scale web applications, and we feel lucky to have the opportunity to ride on the shoulders of such giants.  It is trivial to whip together a proof-of-concept for almost any idea, and the subsequent work to scale your app is significantly less than if you had rolled your own infrastructure.

As with any platform, there are tradeoffs.  The tradeoff with App Engine is that you get an amazing suite of scale-ready services at the cost of relentlessly optimizing to minimize latency spikes.  This is an easy tradeoff for us because App Engine has served us well through several exciting usage spikes and there is no question the progress we have already made towards our mission is significantly more than if we were also building our own infrastructure.  Like most choices in life, this choice can be boiled down to a bumper sticker:

Editor’s note: Chris Chew and Steve Huffman will be participating in a Google Developers Live Hangout on Thursday, November 1st. 

Here is the full Hangout conversation on Youtube:

Tuesday, October 30, 2012

Teaching thousands of students to program on Udacity with App Engine, part 1: Steve Huffman

Cross-posted with the Google App Engine Blog:

This post is part one of a two-part series on how Udacity is using App Engine to teach thousands of students how to program online.

Today’s guest blogger is Steve Huffman, founder of Reddit and Hipmunk. Steve recently taught a web development course at Udacity, which offers free online courses in programming and other subjects. Steve shares his experience using Google App Engine to teach the course.

This past spring I had the pleasure of teaching a course for Udacity, an online education company putting high quality college level courses online for free. I was recruited to Udacity by a former college professor and friend of mine, Dave Evans, Udacity's VP of Education.

When I was a Computer Science student at the University of Virginia, I was fortunate to take a cryptology course taught by Professor Evans. He presented us two ways to get an A in this course. We could either do it the old fashioned way--do well on tests and homeworks as well as completing a course-long project of our choosing; or, we could break into his computer and set our grade to an A. Naturally, we pretended to do the former, while spending our evenings huddled outside Professor Evans' house working on the latter. My team received A's.

It was one of the first times where I felt I was not just completing course objectives as a student, but thinking about real-world problems as a computer scientist. When Professor Evans emailed me early this year inquiring whether I’d be interested in teaching a course on Web Developement, I said, “Yes!” long before my brain had a chance to remind me that I already had a full-time job.

The course I taught was CS 253: Web Development, which aimed to teach students the fundamentals of building web applications. I’ve always wanted to teach-- it’s one of my favorite aspects of my job at Hipmunk. Web Development in particular is appealing because not only is it, in my opinion, the world’s most valuable profession, but even starting from scratch it doesn’t take much time to acquire the skills to build a site that can change the world. I wanted my course to leave students with such skills.

Choosing a platform for CS253

The course would be divided into seven one-hour lectures. After completing the seven lessons, students would have the skills to build a fully-functional blog platform from the ground-up, user accounts and all. I knew from experience that there is a dark side to web development: system administration. You can write all the fancy software you want that works on your own machine, but actually getting it online can be quite the pain. Where do you host it? Which database will you use? Do you know how to install such a database? Do you know how to configure a web server?

Learning the basics of web development in seven lessons was going to be challenging enough, I didn’t want students to have to deal with learning how to be system administrators at the same time. Fortunately, we decided in our first meeting that Google App Engine was the right tool for this course. Despite having never used it myself, the idea of it seemed to fit perfectly. Students would be able to write fully-functional web applications without having to deal with the tedium of installing web servers and databases, at least that was the plan. To be honest, I was a little skeptical at first, but I also didn’t have much of a choice--I wasn’t about to waste any time explaining how to get PosgreSQL running in Windows.

Reflections on App Engine

App Engine turned out to be one of the best decisions we made. Here are a couple of reasons why:

Write locally, deploy globally.
  • With App Engine, you can develop and run your application on your own machine, database and all, and with a simple command, deploy your application to Google’s servers and have it run identically on the Internet. When this worked for the first time for me, I was blown away. I’ve spent a significant, perhaps embarrassing, amount of time deploying code over the years. To see it happen in just a few seconds was astonishing.
  • Students being able to get their code running on the Internet with almost no hassle was one of the most important aspects of my course. First, it gave the students an immediate sense of power. After the first lesson, they would have their own code running live on the Internet! Second, it enabled a really nice mechanic of the course--each lesson would end with an assignment to add a feature to their live website. We could then grade these assignments in real-time. All the students had to do was submit a URL.
Excellent documentation.
  • App Engine’s documentation is superb. I tried to focus the majority of the course on high-level concepts common to all web development platforms; however, it was unavoidable that many parts of the course are specific to App Engine itself. For better or for worse, many of the App Engine concepts I taught I had learned only moments before. I got to know and appreciate that documentation very well. Even some of the more subtle concepts, like how the Datastore deals with replication lag, was all there and clearly explained.
The perfect level of abstraction.
  • A trap many beginner web developers fall into is starting with a very abstract web framework like Rails. While Rails enables a beginner to write simple apps quickly, and allows pros to appear to be wizards, it masks a lot of really important web concepts. App Engine sits at just the right level of abstraction for beginners and pros alike. I think it’s critically important to understand the difference between a GET and a POST, what HTTP headers look like, and how cookies work, for example. These aren’t difficult concepts, and having a deep understanding of them early will carry prospective developers far.
  • While most of the students’ work in my course was probably used only by themselves and our grading scripts, we did spend a fair amount of time discussing how to design web applications that can support millions of users. Once you understand how to design an application that can run across many machines, App Engine will take care of the challenge of actually launching those machines when required and deploying your code seamlessly. Should the website I built during the course lessons,, ever hit the big time, I can rest assured App Engine will scale it with no effort from me.

Teaching CS 253 was a tremendous experience. To date, over 57,000 students have enrolled in the course! Check out some of the cool sites they built on App Engine after just seven lessons:
  • KickSaver (by Connor Mendenhall) - the web app that saves KickStarter projects before they end 
  • Voter Sentiment (by Scott Bartell) - A real time analysis of Twitter sentiment towards the 2012 U.S. Presidential candidates: Barack Obama and Mitt Romney. 
You can see more apps built by Udacity CS 253 students at the Udacity Showcase,

Teaching CS 253 was a tremendous experience. To date, over 57,000 students have enrolled in the course. It’s a project I’m incredibly proud of, and I’m deeply thankful to the folks at Udacity for giving me the opportunity. Furthermore, I’m grateful to Google and the App Engine team for building such a strong product. CS 253 could not have worked without it.

Editor’s note: Stay tuned tomorrow for the second post in this series by Chris Chew, one of the developers at Udacity. He’s going to explain how the Udacity team uses App Engine to power the courses themselves.  Also, Steve and Chris will be participating in a Google Developers Live Hangout this Thursday, November 1st, check it out here and submit your questions for them to answer live on air.

Contributed by Steve Huffman

Monday, October 29, 2012

New Udacity Logo

As many of you have noticed, we've been rolling out new identities across our various social networks... And now we’re pleased to roll out a new logo for Udacity, along with a cleaner design for the home page!  

Our aesthetic continues to evolve to better represent our mission and values. Udacity is an evolution of traditional universities. Our new logo is a play on the old style serif “U” of many established universities. The right end transforms and rises, symbolizing Udacity’s forward progression and commitment to constantly innovating our students' learning experience.

A streamlined sans serif font for "Udacity" reflects the simplicity we value in our user experience. Watch for more changes and improvements to the site in coming months!

Udacity October News!

Happy October! For those who may have missed our newsletter hitting your inbox last week, we wanted to keep everyone in the loop.

For starters, we opened enrollment in four new classes! These focus on contemporary skills blended with programming concepts and computer science subject knowledge. To enhance the classes, we’ve brought in leading tech companies and fantastic researchers / practitioners to teach with us.
  • HTML5 Game Development: This class, brought to you by Google, will teach you HTML5 programming, centered around creating your own browser-based games. HTML5 is an emerging platform for building engaging and immersive web applications.
  • Introduction to Parallel Programming: In this class, brought to you by NVIDIA, you will break out of your linear approach to programming and learn how to harness the power of GPUs and parallel thinking to create lightning-fast programs.
  • Interactive Rendering: What is it about the surface of an apple that makes it look so different from the surface of an orange? In this class, brought to you by Autodesk, you will learn the basics of 3D computer graphics, including the math, physics, and programming necessary to model three dimensional objects. 
  • Functional Hardware Verification: Computer scientists often forget about the importance of, well, computers (and the chips inside them). This course from Cadence straddles the interface between hardware and software, and will teach you how to verify whether hardware behaves as expected.
On the tech side, we are also busy working on supporting new languages in our own in-browser coding environments. HTML5, CSS, JavaScript, and CUDA are in the works, as is an integration with Mathematica from the fine folks at Wolfram. You will have no programs to install or to run, but will be able to learn, think, do directly in your Udacity class!

We look forward to seeing you in meetups, admiring your projects, and most importantly, in the new classes we are launching. Stay Udacious!

Thursday, October 25, 2012

Andreesen Horowitz's Peter Levine: Software Eats Education - An Audacious Undertaking

We're pleased to have Peter Levine join our board and the folks at Andreesen Horowitz supporting our mission to bring high quality, higher education to the world. To kick things off, Peter wrote about our (A)Udacious goals and his excitement to change the world with us!

Software Eats Education: An Audacious Undertaking

Wednesday, October 24, 2012

Harvard Business Review: It's Time to Rethink US Education System

HBR and Tammy Erikson blogs about the US education system and how the next generation of students coming through the education system are demanding changes in how education and learning is delivered.  It articulates many of points we intuitively know about learning and how it's evolving.  Good food for thought on what a modern education system could look and feel like.  What do you think?

HBR: It's Time to Rethink US Education System

Thursday, October 18, 2012

Four New Classes!

Technologies change quickly. While savvy companies are quick to adapt to these changes, universities are sometimes slower to react. This discrepancy can lead to a growing gap between the skills graduates have and the skills employers need.  So how do you figure out exactly what skills employers are looking for? Our thinking: work with industry leaders to teach those skills!

And that’s what we’re doing. We are working with leading academic researchers and collaborating with Google, NVIDIA, Microsoft, Autodesk, Cadence, and Wolfram to teach knowledge and skills that students will be able to put to use immediately, either in personal projects or as an employee at one of the many companies where these skills are sought after.

The classes that are opening for enrollment include:

And coming soon at a later date:

  • Mobile Applications Development with Android
  • Applications Development with Windows 8
  • Data Visualization with Mathematica

Additionally, through our partnership with Wolfram (creator of Mathematica and Wolfram Alpha) we will be integrating new computational tools into our courses. This means that if you want to visualize that amazing new path-finding algorithm you just wrote, the equations of motion you just learned, or the robotic car you just programmed, you’ll be able to easily do that right in the browser!

These classes will be available in early 2013. We’ll keep you updated as we go. Stay Udacious!

Wednesday, October 17, 2012

Udacity's How to Build a Startup: Lean LaunchPad course going Spanish!

Thanks very much to our students and their grassroots effort to translate our courses into different languages.  We're looking into providing tools to better support your efforts on this front: stay tuned.

In the interim, we're also excited to have gotten formal support from Colombia's Ministry of IT and Innovation. They will be translating Steve Blank's entire Lean LaunchPad course into Spanish, so look for a version with Spanish audio coming soon!

Friday, October 12, 2012

Malala Yousafzai, Our Thoughts are with You!

Malala Yousafzai lives in Pakistan.  In 2009, the Taliban regime in her region banned girls from
attending school. As an eleven year old, she wrote a blog (under a pseudonym for fear of being attacked) about her life and her thoughts on education.

On Tuesday, a gunman shot Malala in the head. She is currently in the hospital in critical condition.

Malala’s commitment to educational equality runs so deep that she was willing to risk her life to expose the injustices she lived with. If you’d like to help Malala’s cause, please consider donating to Global Giving’s project to educate 1000 Pakistani girls.

Our thoughts are with Malala and all of our Pakistani students. Thanks to Khadijah for posting about this in the physics forum. You are a true hero, Malala. We hope you get well soon.

Wednesday, October 10, 2012

Work it Harder, Make it Better

Great teaching takes effort. It takes time. In traditional schools, the amazing teachers are the ones who continuously strive to improve their teaching. A class taught by such a teacher will not be the same this year as it was last year.

The opportunity for improvement is even more apparent in the world of online education. In this world, we don’t have to wait a year to make improvements and we don’t have to reteach an entire class. Instead we can take out a piece of a class that didn’t work so well, figure out why it fell short, and then replace it with something better. We can bridge the gaps in our content with additional material. We can supplement confusing topics with additional examples.

So in addition to working on a collection of new classes, we are also focusing on improving what we already have. We’ve already made significant changes to ST101: Intro to Statistics and CS101: Intro to Computer Programming. We’ve recently added some new material to PH100: Intro to Physics. This week, Peter Norvig will be in the office to begin making changes to CS212: Design of Computer Programs and Steve Huffman will be in soon to record some additions to CS253: Web Development.

If you have an idea of how we can improve, please let us know by taking this survey! We want to make the most educational and engaging courses that we can and we would leave to hear your thoughts.

Monday, October 1, 2012

What Can MOOCs Teach Us About Learning? | HASTAC

Cathy Davidson blogs thoughtfully about MOOCs.  Sebastian is quoted in the post.  We agree it's time to look beyond the MOOC hype and understand how we can really impact learning and both educational and career advancement.  The Udacity experiment to push "Learn, Think, Do" continues...

What Can MOOCs Teach Us About Learning? | HASTAC

What are your thoughts?