Socket C ++ or C # Performance

I need to write an application, which is essentially a proxy server for processing all HTTP and HTTPS requests from our server (browsing the web, etc.). I know very little C ++ and it is very convenient to write application functions in C #.

I experimented with a proxy from Mentalis (C # socket proxy), which seems to work fine for small web pages, but if I go to large sites like tigerdirect.ca and browse through multiple layers, this is very slowly, and sometimes requests are not filled, and I see broken images and JavaScript errors. This happens with all of our vendor sites and other heavy content sites.

Mentalis uses HTTP 1.0, which, as I know, is not so efficient, but should the proxy be so slow? What is the acceptable performance loss when using a proxy server? Can HTTP 1.1 make a noticeable difference?

Will a C ++ proxy be much faster than in C #? Is the mentalis code just ineffective? Will I be able to use the C ++ pre-proxy and import the C # DLLs and still get good performance, or will this project call for all C ++?

Sorry if these are obvious questions, but I haven't done network programming yet.

EDIT In response to Joshua's question: I don’t have to write the main proxy server myself if there is a good implementation, but, as I said, I experimented with Mentalis which does not work so well. The final application must be installed on a Windows PC from one installer with a manual setting of 0.

I can write all the necessary registry changes in the installer, as I did earlier in C #.

UPDATE I took the advice of the Aarons and studied the Mentalis code. I fix the problem so that it works with HTTP 1.1, allowing it to work with Chrome and Firefox (Safari 4 on Windows resets the proxy server, although for some reason).

When I tested in FireFox and Chrome, I found that there were no performance problems, which implied that the IE problem was not a proxy server problem. After resetting the browsing history settings, the problem disappeared.

Thanks everyone!

+2
c ++ c # proxy sockets
May 05 '10 at 13:15
source share
3 answers

As you actually develop and code the application, you will make infinitely more difference than the platform you choose.

If you create a server efficiently, it will be efficient. If you create it inefficiently, it will be inefficient. There is no obvious advantage to choosing C ++ over C # or vice versa ... unless you have to learn the whole language from scratch, which is huge negative (it's hard to come up with a good design when you barely know the tools).

Things you may have to understand for this type of application:

  • I / O completion port
  • Thread pools and multithreading in general
  • Network protocols (including HTTP, FTP, TCP, etc.) - especially for error handling
  • Certificates and Signing / Encryption (for SSL / HTTPS)
  • ...

Honestly, you are talking about a nontrivial undertaking here. I don’t want to sound too negative, but what makes you think that you can do a better job without extensive knowledge of basic network protocols and proxy design? Why don't you take a look at the source code of Mentalis Proxy and see if you can improve it and not try to write your own from scratch? Of course, the former would be easier than the latter.

In any case, a socket is a socket; .NET sockets are not much larger than paper wrappers on top of Windows sockets, so performance will not be noticeably different in C ++.

+11
May 5 '10 at
source share

C ++ is not an easy language to learn. Combine this with a lack of networking experience and you are in a whole new territory. If you want to research - great, you will make all the mistakes and learn a lot. If, on the other hand, you need to deliver something by a certain date, go with what is convenient for you at the moment.

+1
May 05 '10 at 1:26
source share

If you want to write a really fast, clean, metal server, go to C ++ or plain C.

C ++ is not a simple language and is easy to use. C ++ requires the discipline to really read and reflect on difficult books. Used correctly, it is the best system programming language.

If performance is not a problem, you can use fluffy tools like C #.

0
May 27 '10 at 8:59
source share



All Articles