Poor Performance of an ASP.NET Application on New Hardware

by Oliver 25. April 2015 22:16

Two days ago I finally did it: I asked a question on serverfault.com looking for advice on why our brand new server performs more poorly than our two older servers.

All the hardware details speak in favor of the new server:

image

But in reality, the older servers with the lower spec outperformed the new server by almost a factor of two! That is to say, for every 1 Request/sec processed the new server needed 4.5 % Processor time compared to 2.6 % on the old server. Here's a PerfMon screenshot of the new server:

Screenshot-20150422-144404

New CPUs are really good at saving energy…

… actually so good, that they will rarely bother to hurry up until you really, really stress them out. Here's a good read by Brent Ozar on an energy serving CPU that would cause certain SQL queries to run two times slower on newer hardware than on the old one! That's exactly what's been happening to us.

Power Plan: From Balanced to High Performance

That brings us to: Power Plans. Windows Server and Client OSes come installed with several Power Plans, and it just so happened that the new server we had ordered with Windows Server 2012 R2 installed had its Power Plan set to Balanced (Recommended). Well, that might be a good choice for the server hoster as it helps keep the electricity bills down but it's absolutely not a good choice if you want your applications to perform well on that server. They will simply be a lot slower than the could be.

So, open the Power Options window by typing "Power Plan" into the start menu or Windows search and check the High Performance radio button:

image

After doins so on that new server, PerfMon would show this much more soothing picture:

image

Now, we have only 1,5% Processing Time per 1 Request/sec processed. That's an improvement of factor 3. Nice!

Lesson Learned

I've learned that I'm not that good of a sys admin, yet. I had been contemplating on the reasons of the poor performance of that new server of ours again and again, I had checked all kinds of settings inside IIS, ASP.NET, and the like. Those are the areas I work in day-to-day. Turns out, I needed to widen my horizon. Thanks to serverfault.com I did. And our server is at last performing as it should.

Happy administrating!

Visual Studio 2013 Update 4 Crashes On Startup – It Might Be GitExtensions' Fault

by Oliver 23. February 2015 22:49

Lately, I've been having a hard time with my Visual Studio installation because one day it just out of nowhere started crashing during startup.

Starting VS with the /SafeMode flag avoided the crash but wasn't of much help to do major work since all my R# syntax highlighting and refactoring tools are not available in safe mode.

First Try: Reset All Your Settings

The first time I encountered the problem I found this answer on stackoverflow.com  helpful which suggests to:

  1. Reset all your Visual Studio settings by calling devenv /resetsettings from a command line prompt or after hitting the Windows key.
  2. Delete the folders %LocalAppData%\Microsoft\VisualStudio and %LocalAppData%\Microsoft\VSCommon

Second Try: Uninstall GitExtensions

Today, VS started crashing again and I was just happy with resetting all of my fine-tuned settings AGAIN. Luckily, a google search brought up this thread on the NCrunch forum and since I use NCrunch for test execution I went to have a look

Here's what Simon had to say there:

I'm thinking the problem was a GIT plugin installed by GitExtensions - I've read other reports about it causing problems, so I've removed it and things seem stable so far.

To verify whether this was true in my case I just went ahead and uninstalled GitExtensions via the Control Panel – and Visual Studio would happily start again! What a relief.

But I Still Want To Use GitExtensions…

After uninstalling, go get the installer again (did you know there's a standalone version without msysgit and kdiff?) and during install unselect all the Visual Studio plugins like this:

image

Now, you should be good to go! I'll try to get back to work now while my VS is running…

Happy coding!

Spartakiade 2015, Berlin

by Anton 20. February 2015 15:20

Andréj und ich nehmen dieses Jahr an der Spartakiade teil. Was ist das?

Die Spartakiade findet vom 21.–22. März 2015 in Berlin statt und bietet Workshops zum Mitmachen an. Bei der Spartakiade kann man sich ohne Zeitdruck ausführlich und intensiv mit einem Thema beschäftigen. Die meisten Workshops sind ganztägig (manche halbtägig). Und weil das wie beim Sport herausfordernd werden kann, heißt die Konferenz „Spartakiade“ – namentlich auch bekannt als Sportveranstaltung :).

DSC_0095

Es sind Workshops jedes Schwierigkeitsgrads aus der Softwareentwicklung dabei – etwas für Leichtathleten, Kraftsportler oder Mehrkämpfer und die ganze Mannschaft. Inhaltlich geht es um Agile Games, Event Storming, Git, Node.js / AngularJS, Raspberry Pie, Funktionale Programmierung, Microsoft Lync und vieles mehr.

DSC_0110

Falls auch du dich anmelden willst: spartakiade.org

DSC_0182

enjoyed the post?

Tags:

Setting up freeSSHd to Connect to its SFTP Server Using SSH Public Key Authentication

by Oliver 14. January 2015 22:59

A while ago I've set up an SFTP server using the freeware freeSSHd which is relatively easy to get up and running. Initially, I created a user/password pair to log into the server.

Using SSH

Last week, we decided to switch to public/private SSH keys for authentication instead of the user/password pair. Among other things, this allows us to script access to our server while at the same time we can avoid keeping a clear text password in one of our scripts. Here's how we've set it up.

Configuring freeSSHd for use with SSH

I'll run you through the necessary steps:

  1. Open an instance of freeSSHd and go to the Users tab. Add or Change a login to use Public Key (SSH only) authorization and enable SFTP access: image
  2. Navigate to the Authentication tab. There you'll find the path to the folder in which to deposit your public keys. If you plan to have more than a few, consider using a subfolder of the default one: image
  3. Open the public key folder in Windows Explorer and create a new empty text file there by the name of the login you've set up in step 1. Make sure the file name is exactly the same as the name of the user and don't add any file extension to it. This is where we'll be pasting a new SSH public key to in a moment: image
  4. Now we will generate an SSH key pair. Locate puttygen.exe on your PC. You can grab it from the PuTTY download page, but it also comes bundled with GitExtensions, or WinSCP, if you use one of these: image [Side note: I use Everything to find such files. It's a great search tool that delivers instant results.]
  5. Start puttygen.exe and generate a pair of SSH keys by clicking Generate ❶: image
  6. Next, copy the public key from the grey text box ❷ and paste it into the empty file you've created in step 3. In my case, this file is called "oliver".
  7. You can now save the private key ❸ to a file of your choice, optionally protected by a passphrase, to use it to connect to freeSSHd via SSH using your preferred tool. I've successfully used WinSCP for testing, as I've experienced several problems using PuTTY's psftp.exe command line tool.

Roundup

Setting up public key authentication in freeSSHd can be tricky. While researching the solution I've stumbled over this blog post addressing the same problem. Its author refers to this setup guide from IBM (pdf) as the source of help so it might be helpful to others out there, as well.

I hope that my step-by-step guide has also helped you.

Happy connecting!

ASP.NET, OWIN and Katana

by Oliver 12. November 2014 13:42

This is a short overview post on OWIN, which (I quote from its homepage)

[…] defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development, and, by being an open standard, stimulate the open source ecosystem of .NET web development tools.

In other words, the OWIN specification aims to put an end to monolithic solutions like ASP.NET WebForms or even ASP.NET MVC in favor of creating smaller, more lightweight application components that can be chained together to configure an application that does exactly what the author intends it to do – and nothing more. In addition, OWIN simplifies development of alternative web servers that can substitute IIS, e.g. Nowin, or Helios, a promising .NET server alternative on top of IIS but without the heavy, 15-year old System.Web monolith (here's a good review of Helios by Rick Strahl).

Katana is a Microsoft project that contains OWIN-compatible components…

[…] for building and hosting OWIN-based web applications.

For an overview of Katana look here. The Katana architecture can be found on the right and promotes exchangeability of components on each layer. It turns out that ASP.NET vNEXT (github repo here) continues the work that has been done by Microsoft in that direction. Here's an enlightening quote by David Fowler, development lead on the ASP.NET team:

vNext is the successor to Katana (which is why they look so similar). Katana was the beginning of the break away from System.Web and to more modular components for the web stack. You can see vNext as a continuation of that work but going much further (new CLR, new Project System, new http abstractions).

The future of ASP.NET looks bright – especially for developers!

Check out my last post on ASP.NET vNEXT and Docker, too.

Interesting Introduction to SignalR

by Anton 11. November 2014 20:10

Two weeks ago Robin Sedlaczek held an introductory presentation to SignalR at the ALT.NET group in Berlin.

The Framework has a pretty simple setup. After talking a little about the specifics, Robin showed us how to program a simple console application with clients and server, where both can push data to each other, and call functions. If you do not want to delve into specifics, the SignalR framework has a powerful API. It uses different techniques to connect server and client – it chooses the best available, for instance WebSockets.

One simple application where SignalR is useful is a chat. Robin also showed us a real-time collaboration tool (similar to Google drawings in docs). Of course I thought about our new (yet unreleased) time tracking application. It may be feasible to use SignalR if we want to update the clients often. That is not a scenario yet, but could be, if we want to show data from others users.

It was a nice experience to once again attend a meeting at the ALT.NET User Group Berlin group.

enjoyed the post?

Tags:

Creating PDFs of HTML

by Anton 7. November 2014 15:47

For our new time tracking web application (which not yet live) we need the functionality to create a PDF report.

Since we use AngularJS to generate the HTML for the reports, I thought it would be nice to just convert that HTML via JavaScript into a PDF. The search for a solution pointed me to jsPDF – a pretty good tool for creating PDF via JavaScript. But its capabilites to convert HTML into PDF are limited (as of late 2014). We needed to convert a HTML table with all its styles into a PDF. I added jsPdfTablePlugin into the mix, but it still did not look good.

So we abandonded the JavaScript way, and let the backend generate the PDF. I added an MVC view that displays the report, which is then captured via wkhtmltopdf. We already knew this process since we use it in our platform tool discoverize generating invoices. It works smoothly.

enjoyed the post?

Tags:

JavaScript | .NET | C# | PDF

ASP.NET vNEXT, Docker, and the Future of Application Development and Deployment

by Oliver 3. November 2014 09:16

It's been an impressive year so far in the realms of software development and deployment, especially with

Now, it took me a while to understand that we're witnesses of nothing less than a revolution in software development.

The Vision: Build Your App Anywhere, Bundle It, and Run It Anywhere (Else)

The clouds have been with us for a couple of years now and have started to provide real benefit beyond "moving your stuff to somewhere else". What's emerging now, with Docker and also the new ASP.NET runtime bundling, is something completely new: Application Containers. They don't have either specific OS requirements – Docker will be supported natively on Windows Server soon, ASP.NET runs on Linux today – nor need they a specific technology stack installed on the target machine (as with PaaS) because they bring all of the necessary runtime along. But they're also not large VMs bundled with your application, which carry a significant maintenance overhead (when using IaaS). Virtualized application containers are the sweet spot between IaaS and PaaS. Go ahead and read that post – it's eye-opening.

Visual Studio 2013 Hidden Gems

by Oliver 17. October 2014 23:13

This post is one of several summarizing some of the sessions I attended during the .NET Developer Days conference in October 2014. Check out the rest of them.

Here are my notes from a whole day of sessions diving deep into Visual Studio and its possibilities, lead by Kate Gregory:

Window positioning

When drag'n'dropping windows you can drop them in any place you like, even in a place where VS suggests to dock it to another window group, by holding down the CTRL key and then releasing the mouse button.

Using the Start Page

image Probably 3% of all developers use it but it's gotten better over the years. You can now pin projects to it so they won't fall of the most recently used list, you can remove unneeded projects by right clicking or open its folder if you forgot where you keep it.

Also, the start age hides itself once you open a project or a file so you don't have to close it by hand anymore.

Navigating Code

If you want to go to the definition of a symbol just get your cursor on it and press F12 which is the shortcut for Go To Definition. That will open the file that contains the definition of given symbol. Now, if you want to drill down into a deeper hierarchy and don't care for the intermediate definitions, give Alt+F12 a try – it's the shortcut for Peek Definition and it will open the definition of the given symbol in an iframe type of window right inside the code you're looking at. You can then use that window to follow further definitions without leaving the current point of interest. [Can't find that menu item in the Express edition, though.]

Also, give bookmarks a try! There's a bookmark manager where you can give your bookmarks a name, group them into folders and the like. Quite helpful to quickly find your way around a large codebase or for presentations.

Finding things

imageThere's great inline find window by now in VS that you can control from your keyboard in no time. Use Ctrl+F to open it with the word prefilled that your cursor is currently on or use Ctrl+F3 to search for the next occurrence of the word your cursor is on. This little tool is really worth getting to know well because it can save you a lot of time when looking for stuff or replacing it.

imageHave you noticed the search text box at the top of the Solution Explorer? There's even a shortcut to get there so you don't have to take your hand off the keyboard.

Be prepared to find even more search boxes here and there, e.g. the Error List has one, too!

Application Lifecycle Management (ALM)

Visual Studio Online is a new one-stop solution for hosting projects and collaborating on them in the cloud. It basically offers cloud-based TFS instances. The basic plan is free for up to 5 users in a project with an unlimited number of stakeholders, who are allowed view burndown charts, backlogs, Kanban, and task boards, and may even create new Work Items. It supports, of course, TFVC but also Git for source control.

In Visual Studio, use the Team Explorer window to work with your remote TFS, e.g. your Visual Studio Online account, but you can choose to manage your project through a web browser just as well. There's powerful work item editor available online, have a look and take a minute to grasp what all it offers:

image

I'd call it impressive.

There's really a ton of features here, and no doubt there are other tools out there to do the same thing. What really cuts it for me:

  1. Visual Studio Online is free for up to 5 users and an unlimited number of stakeholders.
  2. The integration with Visual Studio is seamless. [You can do pretty much all of the management work either in VS or online.]

Sign out of VisualStudio.com

image If you're logged into VisualStudio.com you can log out by opening the drop-down menu next to your login name, choosing "Account settings…" and there clicking "Sign out". Beware that you have to be logged in with a Microsoft account if you want to use the Express version for longer than 30 days.

Debugging

I'll just put stuff into a list here for better readability:

  1. Have you  met the Autos window? Seems not to be included in the Express version but when hitting a breakpoint it offers insight into all variables used on the current line, the previous line and after exiting a function, shows its return value even if you didn't assign to any variable!
  2. The Locals window captures the values of all variables defined in the current scope without the need to add them to the Watch window.
  3. Press the CTRL key to temporarily hide the variable inspector popup window: image -> hidden-in-vs-debug
  4. Pin values from the above window so you'll keep their values in view – even during the next debugging session!
  5. Set your cursor on a line of code and choose Run To Cursor from the context menu to continue running your code up until the line with the cursor. Wow!
  6. Or choose Set Next Statement to skip all code from the current breakpoint onwards and jump to the selected line. Wow²!
  7. Edit + Continue is also great but works only in 32-bit mode :-|
  8. IntelliTrace (in the Ultimate edition) allows you to capture execution traces of your software on a client machine and debug (through replaying) the same set of instructions inside your local VS – Kate Gregory called it Time Travel Debugging ;-)

That's it from the first day. Happy developing!

.NET Developer Days in Wroclaw

by Oliver 15. October 2014 19:39

I'm currently attending the first .NET Developer Days conference in Wrocław, Poland, and will put up a few posts with my notes from some of the sessions I was able to attend.
The conference took place from 14.10. to 16.10.2014 in the Wrocław Stadium.

Here's a list of all posts (I'll update the links as soon as I finish a given post):

There's already been a lot of input and the third day is still ahead of me! I hope I'll be able to update the above list soon.

Happy Coding!

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for jQuery. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our daughter.

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.