Pros/Cons of writing a custom web server
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. 开发者_如何学Python
- 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.
PRO: You can strip the web server down to just the critical parts you need and not have the overhead of all the stuff your app doesn't need/use.
CONS:
You are going to have to re-invent the wheel on a lot of things that you get for free by using an existing web server. For example, authentication, encryption, parsing requests, formulating responses, managing ports, etc.
All of this time will be spent on things that are tangential to you actual development goals. Unless you plan on re-using this web server on a LOT of projects, it is a waste of valuable development time.
You have built a web-server before right? Are you sure that do a better job than the major ones that already exist and were built by whole teams of developers? Are you sure it will be faster? Will it be less buggy than something that has been tested by literally millions of web users such as IIS or Apache?
Biggest CON: you have to reinvent all of the mistakes and security holes that an existing web server platform has already gone through. How much of your time do you want to have to spend dealing with security-related coding issues?
精彩评论