Stack Exchange Open Source Projects

2/22/2012 11:40:53 PM By Felipe Pessoto

O Stack Overflow, assim como toda a rede, chamada de Stack Exchange, é com certeza um dos melhores se não for o melhor site para se usar como exemplo de aplicação bem feita em .NET. Sempre falo do Stack Overflow e tenho muita admiração, pra começar porque foi feito por desenvolvedores .NET renomados. O site é muito rápido e a interface com o usuário é excelente, da até tristeza quando procuro algo no Google e nos primeiros resultados vem algum tópico no fórum MSDN, é tão lento que da tempo de repetir a busca no Google filtrando somente o Stack Overflow e abrir a página antes do MSDN abrir.

Tudo feito no Stack Overflow é planejado pra ser TOP. Se vão mudar uma placa de rede, pesquisam e fazem testes com os firmwares pra conseguir o máximo de desempenho. Todas os requests e queries são monitorados, até o trabalho do Garbage Collector chega a ser otimizado.

Recentemente o Jeff Atwood postou no blog do Stack Overflow sobre os projetos Open Source que eles mantém. São bem interessantes, já planejo usar o MiniProfiler 2.0 no FujiyBlog.

Segue a lista de projetos com as descrições originais:

Dapper is, quite simply, the world’s most elegant .NET micro-ORM™. We created Dapper out of frustration with all the existing .NET ORMs that were out there. It is the simplest and fastest thing that works, the thinnest sensible layer you can put over your database without getting all Enterprisey© on you like, uh, some other ORMs. It is a shining example of the KISS (Keep It Simple) and YAGNI (You Ain’t Gonna Need It) principles in action. If you need to access a SQL database from .NET, try it out. You just might fall in love with it. Read a bunch more about Dapper over on Sam’s blog.


On Stack Exchange, you can log in with any OpenID provider and any OAuth 2.0 provider, including Google, Facebook, Yahoo, and so on. But as of May 2011, we also issue our own credentials for those people who want to have a traditional username/password arrangement. StackID is the .NET OpenID provider we created, so we can be both an OpenID consumer (we accept all OpenIDs, as well as OAuth 2.0 where available) and an OpenID provider — that is, we issue our own OpenIDs that are valid on any website that accepts an OpenID. This in turn is based on the excellent work of the open source dotNetOpenAuth library.


Here at Stack Exchange, Performance is a Feature, and we found the absolute best way to emphasize our shared family value of performance is to keep webapp performance numbers front and center in every .NET developer’s web browser. Yes, even in production. If you are a developer you’ll see a little number in the upper right hand corner on every single Stack Exchange page you load — that’s how long it took to render the page. And it’s a one click operation to drill down, two clicks to take those performance numbers and share them withblame them on someone else on the team. It’s a wonderful system that I can’t recommend highly enough to every .NET developer who works on a webapp. If that’s you, go download it. Now. Remember, we use .NET partly because it really is blindingly fast, but all it takes is a few lines of errant code to throw all those performance benefits (and more) in the toilet. So download and use MiniProfiler to make sure your fast code stays fast!


MarkdownSharp and PageDown

Markdown is, of course, the simple plain-text-alike markup language that we use throughout Stack Exchange for formatting. But we have to convert it from “raw” Markdown to “cooked” HTML and that takes code. We provide two implementations, for server-side C# Markdown use MarkdownSharp and for client-side JavaScript real time Markdown preview use PageDown. I did a lot of the work on MarkdownSharp, but Ben did most everything on PageDown and is now officially maintaining both of these.

Since this gets asked all the time, yes, it is legal to mix HTML of any kind within Markdown. MarkdownSharp and PageDown don’t do any cleanup of the HTML, they only guarantee that valid Markdown will be converted to valid HTML for display purposes. You must bolt on your own HTML sanitization to taste. If you’re looking for basics, start with this C# sanitization routine and this tag balancing routine. They are mostly loops and regular expressions, so trivially translatable to most languages.

Redis is our in-memory key-value store of choice. We started out using it just a little, but now it’s become an absolutely critical and totally indispensable part of our infrastructure, much like HAProxyWe use Booksleeve for pipelined, asynchronous, multiplexed and thread-safe access to Redis via our C# code. Performance here is beyond critical, as we talk to Redis from every web server constantly, and we’ve been through several passes of refinements and improvements already. If you, too, need an in-memory key-value store for your .NET webapp, consider the Redis and Booksleeve combination we use. Works great for us!

Data Explorer

Everything contributed to Stack Exchange is under a Creative Commons license. Stack Exchange Data Explorer is the open source .NET tool that we built so anyone can browse and analyze our creative commons data via standard SQL, at So if you’re looking for a highly flexible, general front end to a bunch of SQL data, SEDE is your huckleberry. For more, see the blog entries we wrote about it.


This is technically something Marc Gravell created before he joined Stack Exchange, but we use protobuf-net extensively (and AFAIK exclusively) for high performance, compact serialization of .NET objects before storing them — and I daresay that our heavy use has driven the current version of Protobuf-net to be at least 3x as awesome as it would otherwise be. I don’t think you’ll find a faster and more elegant .NET serialization library in the world.


This is part of Demis Bellot’s excellent open source Service Stack REST web service framework. And again, something that he created before he joined us at Stack Exchange. We switched to ServiceStack.Text for all our .NET JSON serialization duties a while ago because it was blindingly fast, much faster than any other JSON serializer we could find for .NET. All of Demis’ open source work is of similarly high quality.

Comments (0)