Hi, I am a programmer for 5 or so years. I have really only wrote desktop apps and some websites with only client side scripting in javascript.
What I want to do is run windows server 2012 to host websites and html/css/js content which may be accessed within my game. Also I want to be able to run web services like little programs on the server that can do tasks for me. Last but not least I would like to be able to run SQL server for database storage and access.
While my college is teaching me sql, I have no idea how to setup a server and get all things things up and running and I have no idea how to then create projects and start building these network/web based functionality.
What I am looking for is some book or video tutorials that are geared toward a programmer but beginner in this network/server programming with a focus on the tasks listed above. These will eventually be the systems and things that surround the game I am making with unity.
Thank you!
Update: I do have an older computer already running a copy of Windows Server 2012 64bit on my local network. However I basically just zipped through the install not really knowing what I’m doing though it’s running fine.
Why Windows Servers? The internet runs on Unix/Linux, and for a reason: stability and performance.
E.g. check out Cloud offers: you need to pay more to get a Windows Server, because Windows itself uses so much resources you need stronger Servers. And if you run benchmarks you will cry because you pay more and have a stronger Server but performance/throughput is still much lower than with Linux on the cheap Server…
Edit: and also what tango209 said: if you want to do anything other than presenting web pages in your game, then don’t use web pages for it…
I want to use a windows server for several reasons. First, both my college and my work now use windows servers, which I want to familiarize myself with. I also want to code c# on the server using various forms of .net including asp.net.
The reason html will be served in the game is a package called coherentUI. Also I will install SQL server for my data storage and back end systems.
Windows server just fills the requirements atm. I am sure some day I will run a linux server, but for now I only run linux desktops occasionally.
One tip is to write your web service (in C# in ASP.NET if you wish) so the web service exposes the functions the game will need to talk to and then only allow the web service to talk to the SQL Server database. Do not directly connect to the SQL Server database from the game.
Beyond that, here are some general server tips:
It does not matter if you use Windows or Linux to handle this task. Either could expose functions through a web service that your game could connect to. If you want to use C# in ASP.NET, use Windows 2012 R2.
Regardless of what server OS you use, it will be attacked frequently if it is connected to the Internet and running all of the time. Make sure you read up on some security best practices for the server OS you choose. Start by picking a long random jumble for your administrator (or root if Linux) password. Then set up firewall rules so only the bare minimum ports are open. Make sure everything is updated.
When you write your web service, make sure you don’t have any SQL injection vulnerabilities. Use parameterized queries.
Next, read about good database table design. Learn about creating indexes, since that is critical for performance once your database grows. Similarly, design your SQL statements to return as little data as possible. Don’t use Select *, because that results in two queries (one to find the column list and one to get the rows). Always list the fields you need instead of wildcard selecting the fields. Also, don’t select without using a Where clause. There is nearly never a good reason to grab an entire table, so use a Where clause to grab only the rows you need at the time. Create an index to handle each Where clause you use, so every query runs against an index instead of a slow table scan.
NOTE: These tips are only the first step. Keep reading about server security and performance well beyond these tips.
If you are doing this in part to get experience with SQL Server, web pages, etc., then fine, sounds like you are looking into asp.net stuff already. For the web services in .net look into ASP.NET Web API 2 which I’ve used before for Unity to consume using its WWW stuff.
But, if you not, you’d be better served looking into other options IMHO. Such as GameSparks and the like.
Also, Microsoft has the BizSpark program that’s pretty easy to get into that provides you with basically a full MSDN subscription with some free Azure monthly credits (~$100 IIRC) for 3 years.
I won’t be doing it right. I won’t be securing it properly. I will be trying to learn to do these things from a beginners point of view, and I know enough about computers to know, I won’t do it properly for some time. To get there though I gotta start reading. I need a good book.
The budget internet does. I develop apps for the enterprise for a living. The company I work for only contracts with companies who have annual revenue of $500M / year and above. There’s a mix of Java and .NET. Everything I’ve built over the past 6 years has been C# / .NET on either Windows Server or in Azure. Stability is just fine and performance is driven by the developer.
No, you pay more for Windows instances because of licensing costs.
Nowhere close to accurate. Again this depends on the technology not the server. IIS is general can be slower than Apache depending on what you do with it, but it’s the language / platform that makes the difference. Classic ASP for instance is slow. .NET is pretty fast. .NET on a Windows server is actually faster than PHP on a Linux server in most instances, except for things like File I/O which actually is driven by the OS and natively faster on a *nix server.
But, things are changing there as well. You can bypass IIS altogether and just run your services as standalone apps or as Windows services using the OWIN stack and it’ll be much faster. In that case it’s on par with using Node which excels at raw socket communication without the overhead.
If you’re just learning, stay away from the DevOps side and let someone do the IT side for you. Start out with a shared hosting provider to learn. You can setup a GoDaddy site on Windows server with MSSQL server (100MB database size limit) pretty cheaply. If you want to go the micro-services route you can setup a single MVC / WebAPI site and build out individual services. You could even bootstrap them and build your services as separate projects / DLLs and use attribute based routing.
The other issue you have is licensing. It’s costly to use SQL Server and IIS for an individual because of licensing costs and not being big enough to get an enterprise agreement with Microsoft. Once you outgrow the shared hosting environment, your better bet would be to start looking at Cloud hosting through Azure which makes setting up containers / microservices and database pretty simple. SQL Azure is still a bit pricey imho, but you can use azure table storage dirt cheap.
I work for a similar company, we even do .NET on customer request, but almost never happens. And it is not just the developer, Windows just does not scale, see later point. You know a single major bank that has the core banking systems on Windows? Most important Systems in these companies are on Unix or Mainframe.
I never saw Windows on systems that must handle 30k-100k clients per server (I mean important systems, where zero downtime is tolerated, where nobody in the company can work if the system is down)
Also Windows can fail for unknown reasons, where even MS cannot tell you why it crashed. That is not tolerated in the systems we create normally. (E.g. check the case of London Stock Exchange when they wanted to use .NET, even MS could not tell why the Windows Servers crashed. CEO got fired and is on Linux now without .NET. Also the performance goals have been missed by an order of magnitude, read about it, if you work in this area you must know the history of this famous project.)
This is not true on powerful Servers. Any Windows driven (reasonable) application will be much slower than on Linux. Windows does not scale.
I normally link this:
But as I predicted earlier on this forums, they no longer show results for Windows in newer tests. Also the results that included Windows of some earlier benchmarks do no longer work for the powerful Servers in my Browser. But let me tell you the results of the previous one where they still had included Windows:
On a i7 the fastest Windows framework (pure .NET listener) was at least twice slower than any reasonable framework on Linux. And it was also significantly slower than many “slow” solutions like PHP, Python, Lua and other dynamic stuff. (.NET is an exception, it is even slower on Linux)
The main Problem is that Windows does not scale: if you take a much more powerful Server (i7 vs R720xd dual Xeon) you get like 10 times more throughput if using Linux while on Windows performance stays about the same (so for the extreme case this means Windows is now not 4 times slower than Linux but 40 times slower). This shows that Windows takes almost no advantage of modern powerful hardware…
The real powerful servers on this world cannot even run Windows. And why should they.
[if you want exact numbers tell me, I have stored them somewhere…]
Security:
Another point is security:
My ISP (largest in the country) uses a MS security protocol for country wide WLan for customers. Like many MS security protocols a hash can be used instead of a password, lol. So they use a certificate based solution which is 100% secure if used correctly, but because they use a MS product to implement it, it takes at most 6 hours on a gaming PC to be able log-in as any customer you like (you compute this once and then you have free access forever. I did not report that, maybe they don’t even know. Hackers in my country like it, it means anonymous WLan everywhere…)
MS announced “pass the hash” is finally dead with newest Windows versions. In reality you can now use pass the hash in even more ways than ever before to log-in into Windows… We are at a point where Windows security protocols have to be considered a complete Joke. They had more than a decade to fix the “pass the hash” vulnerabilities in Windows. And what they do makes it worse each time, lol.
Lesson: if you use MS security protocols you better exactly know what you do, otherwise you will be vulnerable as hell…
What are you considering throughput? And what specifically doesn’t scale? It scales just fine for Microsoft who eats their own dogfood, scales fine for Dell, scales fine for Stack Overflow.
Linux will perform better than Windows, across the board but in most cases (except for a couple of things such as Disk I/O), the difference is minimal and not indicative of not scaling. Some tests I’ve seen have even shown Windows make gains and outperform Linux in some tests when you reach high-end server sizes (such as 16-core CPUs).
It would be silly if this was a single point of failure. That’s what load balancing and failover clusters are for. Anyone relying on a single server for this is asking for trouble.
Read about London Stock Exchange… Any amount of load balancing cannot help if you need sub millisecond response times and your servers can crash randomly.
The stock exchange had days where it did not work. And when it worked the banks of London still traded in Frankfurt Germany because it was faster then using London Stock Exchange. It was a monumental failure. And MS gave everything, it was the poster child project that should prove .NET can be used for important things. They wrote many Whitepapers about the project. They run ads about the project, even it was 10 times over the performance goals (10ms vs 1ms). The CEO that gave the go for .NET was fired. That says everything. And they tried everything. MS and the company spend huge amount of money and time to try to save it.
I created systems where response times must be so low that it must be on a single server (any communication with a DB/sister-system for shared state would bring you over the limit). If the application needs a global view of the state, you need a single server powerful and stable enough to do that for the whole company.
There you cannot use Windows:
not stable enough (this system is up 24/7 and can never be down) [of course there are fail-over systems, but they should really never be needed, because you break the performance requirement during the fail-over]
the servers we needed are really powerful (because many requests per second on single system is a strict requirement), you find no servers that run Windows in that range…
I’m familiar with it… it was 8 years ago and has lost the majority of its relevance. Technology doesn’t sit stagnant and Microsoft has made significant improvements to the Windows Server platform since Windows Server 2003 which is what LSE used.
Again I’ll point to Stack Overflow (and the entire Stack Exchange network) which is stable and runs on a SQL Server stack (Windows Server 2012 + SQL Server 2014).
Once again, Stack Overflow. Here are some statistics that I pulled from one of their releases which was in March of 2013 and has only increased since then. This was in a 30-day period:
Hits / Requests: 2,839,549,699
And by the way, there are 2,592,000 seconds in 30 days, so we’re talking 1000 requests / second on average. Of course this isn’t a single server but it that actually allows for more redundancy and failover. In your scenario you require sub-millisecond response times I guess from how many requests per second? And I’m assuming LAN based as well? Not sure how you would account for network latency between your end user and your server, but that’s neither here nor there. The point is, 99.9% of people don’t have that requirement and would actually be better suited with a redundant setup and not a single server.
So you have to design the new London Stock Exchange today: would you use WIndows and .NET? Really? Why? How would you try to justify that before the board? [Any measurement of Windows network stack speed shows you that that alone makes it almost impossible to meet the performance goals.]
In my eyes everyone trying to implement a system like that which needs sub-milliseconds response times with 100% up-time and tries it on Windows with .NET deserves to be fired like that CEO.
The response times needed for Stack Overflow are not even near what performance critical business core systems need.
And of course any important system has fail-overs and if possible load-balancing. But like said, the most really important core business systems of businesses that mostly rely on IT (e.g. bank core systems) have requirements for which Windows/.NET does just not fly. Of course grandmas flower shop is no such case.
Also there are systems that handle over a million requests/sec on a single server, how many Windows servers would you need? For some cases it is just nuts trying to use Windows. Use that tool that fits the problem, as always…
Even MS implements their custom Linux for some of its networking hardware. Even they know that you cannot use Windows for everything.
…sounded like you say large core business applications of today are mostly built with .NET on Windows. My point is that the opposite is true for performance critical core systems of large businesses like banks, you find no Windows there, and for a reason.
I have developed scalable solutions in both Linux and Windows. With a good software design, either platform can scale quite well. Regardless of the platform, ultra high traffic solutions need load balancing and clustering. Anybody that thinks they need to run everything through a single magic server is just begging for trouble, regardless of the OS chosen.
Having said that, I would say the I am biased in favor of Linux in the server room. And that is despite the fact that I actually do think ASP.NET is superior to PHP in many ways. Linux beats Windows in the server room in many ways.
Here is a short list of some of the things that cause me to prefer Linux for the server room:
Linux is usually faster on the same physical hardware. The disk IO is faster under Linux, and a lot of things depend on disk IO.
Licensing. Microsoft’s own employees struggle to consistently understand and explain all of the licensing complexities of all of Microsoft’s various licensing options. On one specific licensing question, I called Microsoft ten times and asked each employee exactly the same question, and each of their answers was different. I do not mind paying for licenses, but I do read the terms of the license and I do take that stuff seriously. Even if you are willing to pay for those licenses, there are restrictions on how you have to use those licenses. For example, for many years it was actually not legal to offer web hosting services using Microsoft Windows due to they way their own licensing terms were written. That is just one of many strange licensing examples that have occurred over the years with Microsoft. Some of the licenses grant Microsoft the right to enter your data center, something the FBI would normally need to get a court order to do.
Compatibility. Linux is compatible with Internet standards. Windows is not even always compatible with its own standards. If you buy and install enough Microsoft software, you will eventually find examples of Microsoft software that cannot work with other Microsoft software. Microsoft does not even care enough to develop upgrade paths for different versions of their own software. For example, build a Hyper-V 2 High Availability Cluster and then try to upgrade to Hyper-V 3 without causing any downtime during the upgrade. It cannot be done, because Microsoft chose not to implement rolling upgrade support for Hyper-V HA clusters, even though their competitors (like VMWare or Xen) have had that feature for years already.
Centralized Software Management. I love solutions like “yum” on CentOS. Installing and updating software is fast and easy on Linux. Windows is sloppy by comparison. Windows Update cannot even update all Microsoft software automatically. Windows 2012 R2 finally added the feature to let admins update SQL Server through Windows Update. In previous versions, admins had to manually manage SQL Server updates. By comparison, the only tricky part in Linux is selecting the desired repo if you want to switch to a newer version of MySQL.
Notice that I did not mention security. I used to despise Microsoft for their lazy attitude about security. Many years ago, one weak minded Microsoft employee even told me it was my own fault if I connected a Windows based server to the Internet, because (according to his stupidity) “Servers should not be connected to the Internet.” That same guy told me the web was just a fad that would never catch on. Of course, that was back before Microsoft.com ran on Windows. Anyway, Microsoft did finally step up and take security seriously, and products like Windows 2012 R2 are generally pretty secure these days. Honestly, even Windows 2003 was a largely decent product. It was massively more secure than Windows 2000 and Windows NT4. I don’t flame Microsoft about security anymore, because I do honestly believe Microsoft takes security seriously these days, even though Microsoft obviously did not take security seriously many years ago.