Pages

What Programming Language Should I Use to Build a Startup?

Often entrepreneurs ask me 'What technology should I build my startup on?' There is no right or wrong answer to this question. It's a decision every company makes for itself, depending on what it's trying to build and the skills of its cofounders. Nonetheless, there are a few rules that one should adhere to. We discuss them in this blog post.

Incident Response Policy

What happens in your company when a production incident occurs? Usually in a typical startup, you will see engineers running around frantically trying to resolve the problem. However, as soon as the incident is resolved, they forget about it and go back to their usual business. A good incident response policy can help bring order into chaos. We provide a sample template in this blog post.

Why Software Deadlines Never Make Sense

We discuss why software deadlines usually don't make sense.

Analyzing Front-End Performance With Just a Browser

We discuss a number of freely available online tools which can be used to analyze bottlenecks in your website.

Why Smaller Businesses Can't Ignore Security and How They Can Achieve It On a Budget

In this article, we show that security is both important and achievable for smaller companies without breaking a bank.

Thursday, December 29, 2011

Caro-Kann proves deadly to International master

Just had a nice win against IM Ilgar Bajarani, European team chess champion in 2001.
This was a 3 min game, but still turned out nicely. As usual Caro-Kann with black proves deadly.

Move Badigo, I (IM) Yampolskiy, A
---- ---------------- ----------------
1. e4 (0:02) c6 (0:01)
2. d4 (0:01) d5 (0:01)
3. e5 (0:01) Bf5 (0:02)
4. h4 (0:00) h5 (0:01)
5. c4 (0:01) e6 (0:01)
6. Nc3 (0:00) Ne7 (0:02)
7. Bg5 (0:01) dxc4 (0:08)
8. Bxc4 (0:02) Nd7 (0:01)
9. Nge2 (0:00) Nb6 (0:01)
10. Bb3 (0:01) a5 (0:03)
11. a3 (0:04) Nbd5 (0:03)
12. Ng3 (0:03) Bg6 (0:02)
13. Nce4 (0:03) Qd7 (0:18)
14. Nd6+ (0:03) Kd8 (0:01)
15. O-O (0:07) f6 (0:01)
16. Bd2 (0:18) Nc8 (0:06)
17. Nge4 (0:06) Nxd6 (0:05)
18. Nxd6 (0:04) Bxd6 (0:01)
19. exd6 (0:01) Qxd6 (0:00)
20. Re1 (0:02) Kd7 (0:04)
21. Qf3 (0:02) Bf5 (0:04)
22. Rac1 (0:03) Rag8 (0:09)
23. Rc5 (0:02) b6 (0:10)
24. Rcc1 (0:02) g5 (0:02)
25. Ba4 (0:02) b5 (0:02)
26. Bb3 (0:01) gxh4 (0:01)
27. Bxa5 (0:07) Nf4 (0:01)
28. d5 (0:15) Rxg2+ (0:08)
29. Kf1 (0:01) Bd3+ (0:04)
30. Qxd3 (0:04) Nxd3 (0:01)
31. dxe6+ (0:06) Ke7 (0:06)
32. Kxg2 (0:10) Rg8+ (0:06)
33. Kf1 (0:04) Nxc1 (0:04)
34. Bb4 (0:13) c5 (0:01)
35. Rxc1 (0:03) cxb4 (0:03)
36. Rd1 (0:04) Qxd1+ (0:04)
37. Bxd1 (0:02) bxa3 (0:00)
38. bxa3 (0:01) Ra8 (0:01)
39. Bxh5 (0:01) Rxa3 (0:02)
40. Kg2 (0:01) Kxe6 (0:02)
41. Bg4+ (0:01) f5 (0:01)
42. Bf3 (0:01) b4 (0:02)
{White resigns} 0-1

Monday, December 19, 2011

Caching through Aspect oriented annotations.

I spent part of the day today instrumenting some of our DALC (data access methods) with caching using the typical paradigm:

public Data FetchData(string key) {
if (cache.HasKey(key)) {
return cache[key];
}

Data d = GrabFromDB(key);
cache[key] = d;
return d;
}


It is a pain, because every single method needs to be instrumented with the same preamble. My next step was to try to use reflection to dynamically modify the generated C# IL code.

A few hours later, I came across this elegant solution using Aspect oriented programming (AOP): http://johnnycoder.com/blog/2009/01/16/caching-with-c-aop-and-postsharp/

Postsharp framework allows you to define custom annotations, so that instead your code becomes

[Cache("FetchData")]
public Data FetchData(string key) {
return GrabFromDB(key);
}

The problem is that the key "FetchData" is not dynamic, and instead must depend on the value of the parameter. There turns out to be a nice solution to that as well : http://www.sharpcrafters.com/blog/post/5-Ways-That-Postsharp-Can-SOLIDify-Your-Code-Caching.aspx

I am going to try it out tomorrow, but it's looking quite promising.

Monday, December 5, 2011

Sunday, December 4, 2011

What is the greatest moment?

Nice quote. I feel this way sometimes when I debug an elusive bug in software having spent hours on it.

"
I remember being in a hotel room in 1967 in San Franciso one night and I'm
flipping the dials after doing all this promoting all day long. There's this
little old jewish guy with a bald head sitting at a piano and he's being
interviewed. And I suddenly realize I'm looking at Igor Stravinski the great
Russian-American composer. The interviewer is saying to him...
"So Mr. Stravinski, what is the greatest moment for you? Is it when you finally
write the symphony?
And he says..."No, No, No...". He sounds like a New York cab driver.
"Is it when you've heard it played the first time by a symphony?"
And he says...."No, no, no...".
"What about opening night when they premier it and herald it as being one of the
greatest works of the 20th century?" And he says...."No, no no...".
"So what IS the greatest moment for you?"
He was sitting at the piano with music on the thing there and he says: "I'm
sitting here at the piano and for 3, 4 hours I'm trying to find a note. I can't
find the note and I'm going 'bum, bum'....'bum, bum'....'bum, bum' for three
hours. Finally after 3 hours I FIND the note. That's the moment. There is
nothing like it. That's everything".

-Dustin Hoffman's acceptance speech, A Lifetime Achievement Award, The Golden
Globe Awards, January 1997

Friday, November 25, 2011

Sporadic delays in BeginRequest of ASP.NET webpages

I've been investigating why some of our ASP.NET webpages sporadically take 10-20 seconds to load, when on average they take 500-700 ms.

The NewRelic instrumentation shows that the delay always happens due to uninstrumented code in BeginRequest.

13,812
100.00%
System.Web.HttpApplication.BeginRequest()0.000 s
0.0
0.00%
13 fast method calls0.000 s
0.0
0.00%
Aptimize.WebAccelerator.OptimizerModule.OptimizerModule_BeginRequest()0.000 s
0.0
0.00%
ASP.global_asax.Application_BeginRequest()0.000 s
0.0
0.00%
System.Web.Security.FormsAuthenticationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Handlers.ScriptModule.AuthenticateRequestHandler()0.000 s
0.0
0.00%
System.Web.Security.DefaultAuthenticationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Security.RoleManagerModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Security.AnonymousIdentificationModule.OnEnter()0.000 s
0.0
0.00%
System.ServiceModel.Activation.HttpModule.ProcessRequest()0.000 s
0.0
0.00%
System.Web.Security.UrlAuthorizationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Caching.OutputCacheModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache()0.000 s
0.0
0.00%
System.Web.HttpApplication+MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()0.000 s
0.0
0.00%
System.Web.Routing.UrlRoutingModule.OnApplicationPostMapRequestHandler()0.000 s
13,578
98.31%
Uninstrumented time 0.000 s
0.0
0.00%
4 fast method calls
After some digging around, I found a few articles that hint this could be due to deadlock issues with Microsoft session module implementation. When you have a page, containing several iframes, these iframes can be concurrently requesting the same session ID from a session state resulting in a deadlock and a delay.

There's a good StackOverflow discussion right here which Demis Bellot pointed me to:
What they recommend to do is to reimplement the session module using MSDN's
custom session handler class (http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstateutility.aspx). The only problem is that that class is not thread safe.

So I started tweaking the class and came up with the following source code, which you can download from: http://www.cs.yale.edu/~yampolsk/SessionDemo.rar
. I am planning to put it into Production next week and measure the results.
Simple Apache benchmarking of default MS session handler and this one, result in almost identical performance.