Monday, September 12, 2011

Windows shared hosting demystified (1&1/GoDaddy)

Recently, I deployed a web based multi-user game. I needed a hosting provider. I have been using one of those cheap 1and1 web hosting packages for some time. This time it was different. The game was developed using C# .Net, Ajax, and SQL Server. I needed a proper Windows hosting platform, which provided all the components I needed. Though I have not had real bad experiences with 1and1 customer service, the reviews were not really good about their service. So, I went to GoDaddy (I will call it Daddy from here on) instead. I did not like Daddy's hosting for two reasons.

  1. The email relay is very slow. You may need to wait as much as five minutes for the email to be delivered. It is unacceptable.
     
  2. I needed to change the transaction isolation level on my database to avoid deadlocks. Daddy won't allow it. This was a deal breaker. 
So, I landed up with 1and1 shared Windows hosting package. Deploying my application on their service was not a cakewalk. The call center in Manila will handle all your issues as long as they are ordinary. Here is a list of issues I faced: 
  1. On 1and1 you cannot create a sub url within your domain as a separate application Example: http://www.ipcolony.com/SicBoOnline cannot be used as an application root. Daddy allows it.
    Workaround: Use subdomain. http://sicboonline.ipcolony.com will work on 1and1.
  2. On 1and1 you cannot use "go" as SQL batch separator.
    Workaround: Use semicolon as the separator. There is a gotcha in this method as well. Read the next point.
  3. You cannot compile multiple create procedure statements in one shot, even with semicolon as the batch separator.
    Workaround: Wrap each create statement within exec statements. Below is the example of two scripts. First example is how a normal person writes a script with multiple statements, and the second example is how to work it in 1and1 environment. I must state that the web based Query Analyzer tool is the culprit. However, I am sure it can be configured to work the way we expect it work. Daddy had it right that too.

    The normal way:
    if object_id('dbo.GetJustDate') is not null
    	drop function dbo.GetJustDate
    go
    
    create function dbo.GetJustDate(
    	@Date datetime) returns datetime 
    as
    begin
    	declare @Ret datetime
    	set @Ret=convert(datetime,convert(varchar,@Date,106))
    	return @Ret
    end
    go
    
    grant execute on [dbo].[GetJustDate] to olgauser
    go
    
    1and1 Way. Make sure that all your single quotes in the original script are converted to two single quotes.
    exec ('
    if object_id(''dbo.GetJustDate'') is not null
    	drop function dbo.GetJustDate
    ')
    exec ('
    
    create function dbo.GetJustDate(
    	@Date datetime) returns datetime 
    as
    begin
    	declare @Ret datetime
    	set @Ret=convert(datetime,convert(varchar,@Date,106))
    	return @Ret
    end
    ')
    exec ('
    grant execute on [dbo].[GetJustDate] to olgauser
    ')
    
     
  4. Some controls provided in Ajax Control Tool Kit (Framework 3.5) did not work right. Workaround: Set attribute CombineScripts="False" for ToolkitScriptManager. Believe it or not Daddy had this one right too.
        
        
    

     
  5. Both Daddy and 1and1 do not support installing custom Windows services in the shared hosting environment. It is understandable. The following code shows you how to launch asynchronous processes from your ASP.Net pages using a time based or a button click trigger.
    delegate void DoStuff();
    DoStuff myAction = new DoStuff(SendEmails);  // SendEmails is some long running function, which will get launched asynhronously
    myAction.BeginInvoke(null, null); // This statement will invoke SendEmails and bring the control to the next statement immediately.
    
     
  6. Highest supported .Net framework version at the time of writing this blog (September 2011) is still 3.5.
     
  7. One major lesson I learned from this deployment is to work with medium trust for web applications. A lot of functionality, which you take for granted in your development platform, simply does not work in hosted medium trust environment. For example, I used mutex to make sure that I was running only one copy of certain part of the code. I had to change this code because it simply did not work under medium trust. 
At every hurdle, both Daddy and 1and1 will try to sell you their Virtual Hosting. Never give up, never surrender. There is always a workaround.  I personally think that Daddy does a great job in the domain registration area.  However, when it comes to hosting, I find more value with 1and1 shared hosting for both price and performance.

2 comments:

  1. Above all information is excellent and you have shared great knowledge through this post here,Register a Domain

    ReplyDelete
  2. Support is fine, they do not offer help though. Their htaccess support is a complete joke, they might aswell not even offer it. My website wont even load if you dont add the www infront of it, but it is cheap.

    ReplyDelete