4-page Case Study
Posted: 3/10/2010
13799
Rate This Evidence:

Stack Overflow Developers See Faster Web Coding, Better Performance with Model-View-Controller

When a couple of renowned developers decide to create a Web site dedicated to helping the world of developers share technical information amongst themselves, they need to create a site that is efficient, scalable, and easy to use. That was the challenge facing Jeff Atwood, author of the Coding Horror blog, and Joel Spolsky, author of the blog Joel on Software. As they planned to create Stack Overflow, a question and answer site for developers, they wanted to find a tool that would enable them to use a Model-View-Controller (MVC) approach, which simplifies application programming and separates application logic from the view state. They built their site using the Microsoft ASP.NET MVC Framework, part of the Microsoft Web Platform. The site supports some 1 million page views per day and hosts more than 500,000 questions, associated answers, and discussion.

Situation

Two prominent bloggers in the world of software development wanted to create a Question and Answer Web site that

*
* It is reassuring to know that Microsoft will continue to build upon and support its MVC framework because we’re huge fans of the .NET Framework, C#, and Visual Studio. We love these tools. *

Jeff Atwood
Co-Founder, Stack Overflow

*
would provide a central repository for accumulating programming wisdom as developers posted questions and their peers posted replies.

Jeff Atwood, developer and author of the popular programming and human factors blog Coding Horror; and Joel Spolsky, developer and the author of the software development blog Joel on Software, and founder of Fog Creek Software, envisioned their Web site as a community-run organization similar to Wikipedia. The two also saw the site as incorporating aspects of blogging as well as community voting in the spirit of the Digg and Reddit social news Web sites in which the prominence of information is based upon user ranking of its relevance.

The mission of the site was summed up in a blog entry by Atwood that reads: “None of Us is as Dumb as All of Us.”

Atwood and Spolsky wanted to create a site that behind the scenes was simple and fast, with code that was lean and scalable. They were dissatisfied with traditional Web development approaches that used an abstraction layer and that embedded code on Web pages to preserve view states. In addition to potentially slowing response rates, they were concerned that storing code on pages could adversely impact search engine optimization because view state information at the top of a page could potentially lessen the relevance a search engine accords to the actual page content found lower on the page.

(Note: This case study was completed before the release of ASP.NET 4. With ASP.NET 4 View State within applications is more easily controlled. You can also get cleaner, semantically correct and CSS friendly HTML markup from server controls and even closely manage the IDs for rendered markup. With built-in URL routing you can also build your application to use and generate clean, search engine friendly URLs.)

The two developers wanted to create their new solution using a Model-View-Controller (MVC) approach, which simplifies application programming. MVC architecture, first described by Trygve Reekskaug in 1979, uses a design pattern based upon a model which provides a data representation relevant to the needs of the application; a view, or interface, for interacting with the data model; and a controller for mediating between the view and the model objects. The three together are sometimes referred to as a triplet, and MVC-based applications can be assembled as a series of triplets, each independent of the other.

The two wanted to create their site using the Microsoft Application Platform, but needed an MVC solution. “We were definitely sticking with the Microsoft stack because we like the Microsoft stack,” Atwood says. “We’re big fans of the language C#. Historically C# has evolved rapidly, and in ways that we like. To stay within C# we were preparing to create our own MVC implementation, but then we heard about the beta version of the Microsoft ASP.NET MVC Framework.”

Solution

Atwood and Spolsky created their new site—Stack Overflow—using the ASP.NET MVC Framework, the Visual Studio

s
s
2008 development system, and the Microsoft .NET Framework 3.5, which are all part of the Microsoft Web Platform. The site, which was created within two months, proved popular and was able to scale to support what turned out to be rapid growth.

“Stack Overflow has grown incredibly fast,” Spolsky says. “After a year in business, it gets over a million page views most weekdays and currently stands as the 817th largest site on the Internet, according to Quantcast. It reaches 5.2 million people a month.” At last count the site hosted 500,000 questions along with the related answers and discussions, ranked according to what the community felt were the best responses.

The two have repurposed the same code to broaden the scope beyond programmers, launching sister sites including Server Fault, for system administrators, and Super User, for computer “power users.”

A spin off of the software, called StackExchange, has been released by Fog Creek Software to allow third parties to build Stack-Overflow communities around other topics. “You can use the same software to create a Q&A site about anything,” Atwood says. “Someone could create a Stack Overflow Q&A community for airplanes, or stamp collecting, geology, or any other area of interest.”

*
* Stack Overflow has grown incredibly fast. After a year in business, it gets over a million page views most weekdays and currently stands as the 817th largest site on the Internet, according to Quantcast. *

Joel Spolsky
Co-Founder, Stack Overflow

*
Stack Overflow was created using the Microsoft Web Platform, which in addition to development tools includes the Windows Server 2008 operating system, Internet Information Services (IIS) 7, and Microsoft SQL Server 2008 database software.

The basic elements of Stack Overflow include:

  • Load Balancing. Users entering the stackoverflow.com site are first handled by a load balancer, which assigns a user to one of several Web servers according to IP address. Users continue to be assigned to the same server for as long as they have the same IP address. Stack Overflow uses the open-source HAProxy for this load balancing.
  • Presentation. Customers browse pages served by Windows Server 2008 Standard, through IIS 7.5. The Web servers are computers with Xeon quad core CPUs and 8 gigabytes (GB) RAM. When a user submits a question or an answer, their information is written to the database using the lightweight LINQ to SQL database abstraction layer.
  • Database. The database is hosted on a dedicated server with 2 Intel Xeon quad core CPUs and 48 GB of RAM, and runs Microsoft SQL Server 2008 Enterprise. Stack Overflow takes advantage of the Online Indexing feature, introduced with SQL Server 2008 Enterprise, which enables table re-indexing while the database continues to run.

“We designed this to be a next generation Q&A site,” Atwood says. “We tried to combine aspects of Wikis, in that everybody can edit everything once the system learns to trust them. Voting, as with DIGG and REDDIT, are an important component. Stack Overflow has a reputation system which comes out of the voting, so as other people vote your content up that increases your reputation score and it unlocks different abilities on the site as the system learns to trust you. It has elements of blogging in that there's a strong sense of ownership. When you create a question you're the owner of that question and you have special privileges as you curate that question. And, like a blog, people can post comments. We wanted to synthesize the best of what we saw in all of these types of communities and bring them all together into one simple site.”

Benefits

Building the Stack Overflow solution using the ASP.NET MVC Framework, the .NET Framework 3.5, Visual Studio 2008, and other elements of the Microsoft Web Platform gave the site the high performance and fast development that the developers had anticipated they would gain from using an MVC approach. Developers found that testing and

s
x
code maintenance was easier using the ASP.NET MVC Framework. The company has also benefitted from the strong developer community that has emerged to support the ASP.NET MVC Framework.

High Performance
The Stack Overflow team was impressed by the performance of the site they created using the Microsoft Web Platform. “Our site is definitely faster than if we had created it with a more traditional abstraction-based Web architecture,” Atwood says. “The .NET Framework is responsible for much of the speed we see, but ASP.NET MVC plays a role because it is so lightweight. It enhances performance.”

The high performance also contributes to the real-world scalability Stack Overflow has enjoyed. “I want to emphasize that MVC not only works from an architectural standpoint of clean code and sensibility, but it also scales really well in the wild,” Atwood says.

Fast Development
Stack Overflow developers credit the clean separation between presentation code, business logic, and the data model they gained by using the ASP.NET MVC Framework with enabling faster development than they could have achieved using abstraction-based Web development models. The developers also praised the low-level HTTP control they gained using ASP.NET MVC.

“The first thing that saved us time was that Microsoft created an MVC framework so that we didn’t have to create our own,” Atwood says. “ASP.NET MVC provides a simple framework that enables developers to work very efficiently. It mapped very well to our mental model of what Web development should be.”

The developers liked the design of ASP.NET MVC. “Microsoft’s MVC implementation is well designed in the sense that it anticipates all the standard work a Web developer would have to do,” Atwood says. “So there is great coverage for the basics, and a clean framework that enables you to go far beyond the basics. We never felt that there was something that we couldn’t do within the MVC framework.”

*
* An MVC implementation was needed. Microsoft created one, and it is generally accepted within the Microsoft developer community that they did a great job on this. *

Jeff Atwood
Co-Founder, Stack Overflow

*
The openness of the framework was appreciated by the developers. “ASP.NET MVC is very pluggable,” Atwood says. “Microsoft allows you to use your own viewer, for example. One of our developers loves jQuery [an open-source JavaScript library] and so we use jQuery, which is supported by Microsoft’s implementation of MVC. We also like that Microsoft has posted the source code for ASP.NET MVC on the CodePlex open-source site.”

Easier Testing and Code Maintenance
The Stack Overflow team is enjoying the separation of concerns that is inherent to an MVC approach to development, finding that code written with an MVC pattern is easier to test and maintain because logic isn’t integrated into the view state.

“With MVC you have a more logical structure for the code,” Atwood says. “By keeping application logic in the controller or data model, it is easier to create, test, and maintain the code. The more traditional method of embedding a lot of code into the view makes for cumbersome development and can create difficult testing scenarios. MVC enables a more direct control of HTML than working through an abstraction layer, and this also makes it easier to test and maintain the code.”

Strong Community
Atwood says he enjoys the strong community he sees developing around the ASP.NET MVC Framework. Developers are excited to have an MVC implementation designed to interoperate with Visual Studio, the .NET Framework, and other elements of the Microsoft Web Platform. He identified Microsoft’s posting of its MVC source code to CodePlex as representing a large contribution to the sense of community that is developing around the product.

“During the beta phase, some common bugs were identified by members of the developer community,” Atwood says. “The difference was that this time we didn’t have to wait for Microsoft to post the bug fixes. Someone in the community just posted their own fix, because they had access to the code. The community is way faster than a company can be. We just downloaded the fix and were on our merry way.”

With Microsoft at the core of the community, Atwood likes the fact that Microsoft will continue to enhance the MVC Framework.

“A basic rule of programming is to never write what you can buy or get for free,” Atwood says. “An MVC implementation was needed. Microsoft created one, and it is generally accepted within the Microsoft developer community that they did a great job on this. It is reassuring to know that Microsoft will continue to build upon and support its MVC framework because we’re huge fans of the .NET Framework, C#, and Visual Studio. We love these tools. Part of the reason we built Stack Overflow was to show people: ‘Look, you can build really awesome stuff with this stack.’”

Summary
In summary, Stack Overflow found the MVC solution it was looking for with the release of the ASP.NET MVC Framework. The company has found that the ASP.NET MVC Framework enhances performance and enables faster development and easier code testing and maintenance.


Microsoft ASP.NET MVC
ASP.NET MVC is a free, fully supported framework that enables developers to quickly build standards-based, SEO-friendly Web sites by offering complete control over the HTML and URLs. It also eases collaboration, development and management by enabling a clean separation of the functional areas, providing Visual Studio tooling support and facilitating test driven development. ASP.NET MVC runs on top of the existing ASP.NET 3.5 runtime, enabling developers to take advantage of Model-View-Controller design patterns. The Microsoft .NET Framework 3.5 is Microsoft’s managed-code programming model for developing software on the Windows platform.

For more information about the .NET Framework, please go to:
www.microsoft.com/netframework 

For More Information
For more information about Microsoft products and services, call the Microsoft Sales Information Center at (800) 426-9400. In Canada, call the Microsoft Canada Information Centre at (877) 568-2495. Customers in the United States and Canada who are deaf or hard-of-hearing can reach Microsoft text telephone (TTY/TDD) services at (800) 892-5234. Outside the 50 United States and Canada, please contact your local Microsoft subsidiary. To access information using the World Wide Web, go to:
www.microsoft.com

For more information about Stack Overflow products and services, visit the Web site at: www.stackoverflow.com

This case study is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.

Document published March 2010

Solution Overview



Organization Size: 7 employees

Organization Profile
Stack Overflow is a Question & Answer Web site for the developer community, reaching 5.2 million users a month, and storing the answers for and discussion about more than 500,000 technical questions.

Business Situation
As Stack Overflow developers began planning the Web site, they wanted to use a Model-View-Controller (MVC) approach to simplify development by keeping application logic separate from the view state.

Solution
The company developed its Web site using the Microsoft ASP.NET MVC Framework, the Microsoft .NET Framework 3.5, and Visual Studio 2008.

Benefits
  • High performance
  • Fast development
  • Easier testing and code maintenance
  • Strong community

Hardware
  • 2 Web tier servers with 1 Intel Xeon Quad Core processor and 8 GB of RAM
  • 1 database server with 2 Intel Xeon Quad Core processors and 48 GB of RAM

Software and Services
  • Microsoft Visual Studio 2008
  • Windows Server 2008 R2 Standard
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft ASP.NET MVC
  • Microsoft .NET Framework 3.5

Vertical Industries
IT Services

Country/Region
United States

Languages
English

RSS