I have created an ASP.NET Webforms web application which basically inetracts with the code behind via jQuery.ajax method.
- The data on page should be refreshed every 1 seconds and is about 1KB per request.
- The web app will be hosted on an intranet. So it has a reasonable speed for such a refresh rate.
- I use ASP.NET Development Server.
- The server side code takes about 20 milliseconds to execute (ideal for me), but (using firebug) every request from client, takes about 1.5 to 2 seconds to go back and forth (Which is related to sending XMLHttpRequest to my web server and receive the callback data. And which is not ideal for me) and I can’t find a workaround to speed it up.
Now, I have been advised from a colleague to write my custom web server to handle the page and interact with that web server by using javascript on the page; This way, I can put my business logic on my created web server and speed things up effectively. (compared to using IIS or ASP.NET Development Server).
Basically, I don’t have any idea about this approach.
I’d be pleased if anyone tells me about the pros and cons of writing my own web server and the effect it has on data transfer rate in my custom scenario.
Don’t do that.
IIS is fast. There is no reason to believe you will be able to write a server yourself, that is significantly faster. A custom web server will add exactly zero additional value, but it will take you some development time to implement. And you will have to worry about security, maintaining, etc.
If you don’t need the overhead of an ASP .NET page, WCF services hosted in IIS, or just a plain simple IHttpHandler are nice options. I am quite convinced you can overcome your performance issues without a custom web server.
Try measuring what is taking the time. For instance, measure your server-side execution time first. Then measure transfer times (for instance, using Fiddler). Which one is taking the time ? If you do a lot of work on the client (like processing received data), that might also be the reason for the delay.