Home / Hosting / Mono Key Duplication Error in High Traffic Environment Workaround

Mono Key Duplication Error in High Traffic Environment Workaround

After setting up the Auto Scaling feature in the Amazon cloud to automatically fire up and terminate virtual machines, depending on how much traffic there is, I ran into some issues with Mono.

In my environment I run Mono 3.4 using the Cherokee web server on Ubuntu 14.

Apparently there is a bug (that actually should be already fixed according to http://lists.ximian.com/pipermail/mono-bugs/2013-May/113692.html) which leads to erroneous Mono instances when there is high incoming traffic during startup of that instance. The bad thing is that this instance of Mono will then not recover during subsequent calls, only killing the process helps. I saw two kinds of this error, one with key duplication for key “roleManager” and one for key “sessionState”.

The stack trace of the error looks like this:

In my web.config neither role manager config entries, nor session state entires were present. But each web.config used in your own projects derives from a global web.config (just like on IIS and Windows). The location for that global web.config on Ubuntu for .NET 4 web apps is /usr/etc/mono/4.5/web.config.
Commenting role manager and session manager in the httpModules section will actually fix the problem.

So the pitfall of this workaround is that you can only use it if your web app does not use sessions and is also not using the role manager / membership functionalities.

Thanks for reading, hope this helps somebody to get Mono very stable in a high traffic production environment.


6 thoughts on “Mono Key Duplication Error in High Traffic Environment Workaround

  1. Marlon

    19 Jan on 2015 at 8:28 pm

    Great post. To avoid overriding your global web.config settings, however, you can also simply add remove name=”session/rolemanager” entries to your app-specific web.config

  2. Andrus

    22 Mar on 2015 at 9:56 am

    I opened http://lists.ximian.com/pipermail/mono-bugs/2013-May/113692.html again since this issue still occurs.
    Adding

    Does not remove those modules in Windows so it is not possible to debug application in windows. In Mono adding those lines makes session object undefined. So it cannot used if application uses sessions.
    How to fix this and allow applicatino to use session ?

  3. Donna

    17 Jun on 2015 at 1:17 am

    This is a comment to the webmaster. I came to your page via Yahoo but it was hard to find as you were not on the front page of search results. I know you could have more traffic to your website. I have found a company which offers to dramatically increase your rankings and traffic to your website: http://garye.co/8k I managed to get close to 1000 visitors/day using their service, you can also get many more targeted visitors from Google than you have now. Their services brought significantly more traffic to my site. I hope this helps!

  4. jual genset perkins

    23 Oct on 2015 at 8:45 am

    Good respond in return of this difficulty with real arguments and telling all about that.

  5. Lemuel

    30 Nov on 2015 at 1:09 am

    What i do not understood is in reality how you’re now not actually a lot more well-appreciated than you
    might be right now. You’re very intelligent.
    You realize therefore significantly with regards to this topic, produced me in my opinion consider
    it from numerous varied angles. Its like women and men don’t seem to be involved except it’s one thing to accomplish with Woman gaga!

    Your own stuffs outstanding. Always handle it up!

  6. odwiedź stronę

    21 Dec on 2016 at 3:51 am

    Pretty great post. I simply stumbled upon your blog and wanted to mention that I’ve really
    loved browsing your blog posts. After all I’ll be subscribing to your rss feed
    and I hope you write again soon!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">