views:

237

answers:

5
  • I want it to work on windows servers.
  • It will be a cloud type server - it'll consist of modules\parts running on different machines all over the world using http\tcp + upnp to connect to each other
  • There are going to be controlling\monitoring\observing modules on each machine to provide stats on performance
  • This net is going to be working with large amount of VIDEO\AUDIO life streaming\broadcasting data
  • It is going to use FFMPEG for re-encoding and OpenGL, OpenCV and such for filtering (.NET wrappers exist and work BTW)
  • It will not use any WCF or IIS
  • I want to develop it in team of 2-4 developers, smart students.

So is it OK to create this in C# .Net or I shall not waste my time on promises of ease it could provide to a developer and go C\C++?

So is it reasonable to write a server application in C# in my case?


Offtop - why not WCF

Warning: it gets way to subjective in here.

WCF is grate when you have big corp with relatively small data exchange per one session of service.

When you have video, LIVE video, it all gets complicated. Large amounts of data, lots of users stream in and out from your service at the same time.

Try to do live video streaming over http binding - than try it with others than you'll see why I do not like idea of live streaming with WCF - it is slow, with way2much not needed for live streaming info and after all have you ever seen a live video streaming app on WCF? No - you haven't - may be you have seen +- live video on Silverlight + IIS pair which I do not like because it is just for Silverlight\WindowsMediaPlayer video streaming solution while I want more than that.

I love to have cross-platform clients with reach UI’s. And I do not like (it is all here my personal opinion - so it is subjective) Silverlight+IIS+WCF group. So what shall I do - right go to sockets, streams in such old and simple formats like FLV and Flash as back end client - Simpler in development in some parts, more conservative way of doing live video over the web than one you get from MS today.

I love Flash FLV live streaming because you just open socket and start sending live FLV video data onto it (for each user FLV header and than FLV "TAG's", one by one: video tag, audio tag, video tag, audio tag etc) and Flash plays it! With no special\unusual code. It is fast, easy in supporting, and does not make client need anything new\unusual. And you on server side can take grate use of that "TAG" form of video\audio data representation.

So that is in short why I just do not want to use WCF - hard to get live video playing out from it on client side, no general benefits for live video server.

And when most of live data goes thru sockets why to bother with using WCF for service management.

During last half of 2009 and first half of 2010 I was getting into WCF, live video streaming, silverlight and flash, comparing process of client\server creation, reading different formats with a team of wary interesting developers. In general at the end of project we had lots of mini servers streaming live data and lots of different clients receiving it. Comparing all we've done we came to conclusions which are near one I present you here.

That is why I do not want to use WCF in my nearest project - I do not want to think about how to deliver media data, I want to focus on its filtering\editing.


Why the question appeared

We started playing with FFmpeg\OpenCV in C, and it is pretty simple to manipulate data using them... in C... on Linux...

But when we started to play with there .Net bindings (we are now playing with Tao.FFmpeg) we found that in most cases we end up playing with C# Marshal a lot, and having 2 variables for its C analog (problem of pointers) and so on. I hope we will not see such problem with Emgu CV but steel it makes me a little bit afraid...

+2  A: 

If you want C# and also cross-platform abilities, your development will have to target the Mono platform (or another cross-platform .NET runtime, if you can find one). You might have to give up VisualStudio, and maybe some Microsoft-specific libraries and tools, but you can still have C# on multiple platforms. Just make sure you start the multi-platform building and testing EARLY in the process or it will be hell to change things later.

FrustratedWithFormsDesigner
ok... lets not think about cross-platform stuff - it was my bad sorry. dispite that if we are talking only about windows what can you say?
Blender
@Ole Jak: If you remove that requirement, then none of the others would push me in either direction. You'd have to have some other business requirement (experience of developement team, cost of tools, etc...) to help make a decision.
FrustratedWithFormsDesigner
Updated... A littel bit.
Blender
+6  A: 

I think it's entirely reasonable. The benefits of C# with regard to ease of development will greatly outweigh any performance drawbacks of not using C++.

C# is generally more cross-platform than C++. True, C++ is a cross-platform language, but there are large differences between the APIs that C++ programs use to interact with the system. C# and .Net/Mono have a much more standardized interface to the socket layer.

Finally, with ambitious projects like this, getting the project into a usable form is a much more important goal than getting the highest performance possible. Performance only matters if the project is complete. Write it in C# because that will give you the greatest odds of completion. Then worry about performance.

Kennet Belenky
+5  A: 

I'm not exactly sure why people have brought up Cross Platform concerns as clearly the OP has stated the app will run on Windows.

As to the actual questions.

  1. Can you build a server application that communicates via tcp/http in C# that does not have to run in IIS. -> Yes.
  2. Can you build a server application that is performant and scales in C# -> Yes.
  3. Can you do so with Students -> Maybe. Depends on the students... ;) But that is irrespective of the language in use.

Is this something I would do? Yes. We've done that. We have a c# app running on approximately 20,000 machines right now that are communicating effectively over tcp. We aren't using WCF, but we did decide to use RESTful style services over http for the data transfer.

Our biggest issue was simply tuning the app to transfer the "right" amount of data over the wire at a time. This network is for data collection and storage. It's averaging around 200GB of data collected a day..

UPDATE
I wanted to clarify a bit about the above app. The 20,000 machines at the above installation are clients (XP, Vista, 7, 2003 Server, and 2008 Servers). There's only one data collection point server in the mix. The clients post data to the server, when connected to a network, once every 45 seconds. Roughly 97% of the machines stay connected in this manner, the rest connect a couple times a week.

This works out to the server processing about 37 million requests a day.

Now, to be sure, each request is relatively small at around 5KB to 6KB each. However, the shear number of requests shows that a C# application can handle managing those connections, which is the bigger part of the OP's problem.

Because the OP's files are large (Video), then the real issue is simply in data transfer. Which will be hindered more by hard drive speeds, as well as network speed and latency. Those issues are irrespective of which language you are working in and will limit the number of connections per server based on available bandwidth.

Working this out let's limit it down to one server for an example. If you have a video rate of 400kb/s then and a 25MB connection to the internet, then that box could physically only handle around 62 simultaneous connections. Which is so FAR below the number of connections our app is doing as to be a rounding error.

Assuming perfect network conditions (which don't exist), pumping that internet connection up to 100MB (which can be expensive) means a 4x increase in simultaneous connections to 240; still completely manageable.

However, the network is only one side of the equation. Drive speed on the servers matters a lot. You better have a good disk array capable of continuously delivering that amount of data. I know drives claim 3GB data transfers, but a drive which can saturate the channel has never been built. Which means serious planning and money in the server setup.

The point of all of this is to say that the language doesn't matter one bit in your situation. You have other much larger contention issues. With that being the case, go with the language that will help you get the project done faster.

Chris Lively
Check revision history. Original question said `...(in plans future Linux ports).`
FrustratedWithFormsDesigner
so.. Aproximatly 2mb/second (~200/24/60/60) so at a rate of video 400kb\s you d have 5 users at a time.. (ofcourse you have regional traffic so I am incorrect) but my point is - all big video editing servers I've seen were written in C\C++... BTW littel post update
Blender
@FrustratedWithFormsDesigner: Missed that. Thanks.
Chris Lively
+4  A: 

Why stop at C#, if you (possibly) want cross-platform, write it in Python or similar, you'll find that the networking aspects of a scripting language are far better than C# (as that's pretty much the role scripting languages are put to nowadays, running web-based servers).

You'll find developer productivity is much improved over C# (just as C# has better productivity over C++), and there are lots of people who know and want to work on these systems. It sounds like performance of the servers themselves is of less importance than the networking, so it appears that script would be your best choice. Plus ffmpeg libraries are more tightly integrated with python using pyffmpeg than C# (well, mostly).

And it'd be a lot cooler, more fun, and very much cross-platform!

gbjbaanb
+1  A: 

If the target of the application is to run only on Windows platforms, I'm completely sure to write this application in C#. Many applications like that can be running right now and we don't even know that.

If the target is to run on multiple platformms, you should encapsulate first all the problems that a non-windows platform can bring to your application.

Why do you have to write it in C++ if, in this case, C# is capable to do everything that C++ does? I would use C++ to program things on hardware-level things, like a robot or something else. To write a server application, C# will fit very well what you want, it was designed for these things.

And C# is cross-platform, you just need the right tool to make it work on a specific platform.

Fabiano