Unity + SmartFox + Amazon EC2 = Win!!

I’ve been testing out Unity 3D … with the goal of creating a light virtual world application. I’ve been using the SmartFox .NET/Unity API … and it’s been working great!! I have no prior networking type experience … but I had a multiplayer game up and running in less than 24 hours.

The only concern I had was the server side and being able to scale depending on traffic and space.

Then I learned of Amazon EC2 (Elastic Compute Cloud) and it has been heaven sent … I can now deploy Smart fox on EC2 and scale up or down dynamically at a lower cost than if I was using a dedicated server provider.

If you haven’t heard of Amazon EC2 … check it out here Amazon EC2 - Cloud Compute Capacity - AWS

Also check out Smart Fox http://www.smartfoxserver.com/

Hey congratulations!! I’m very interested in the topic. Indeed I have heard about Amazon EC2 and SmartFox before. One question I have, which is the benefit of using SmartFox? I have read you can create a server just defining a Unity client as host. I want to learn :slight_smile:

Happy that you like it! And yes - there is a EC2 license thing if you ask the SFS guys. Very cheap way for an indie to go down the MMO road.

Cronodragon - you can try out some of the recently released tutorials:

http://www.smartfoxserver.com/forums/viewtopic.php?t=4629

/Thomas

sorry for being dumb but i cant figure out what this is…
it sounds like it is a computer/server you can use and only get charged for how much/long you use it. but i have no way to calculate how much id pay since i dont really know what to input…
ill assume it runs for 24 hrs a day and 30 days a month? that seems safe
. also do you have an ip or domain, api etc you use to connect to this server? does it function like a dedicated server?

there is a cost calculator for the EC2 system on the pricing page or one of the related pages, that will give you an idea of the costs.

but it won’t help you much. without having your server and some realworld testing metrics you can neither estimate the cpu consumption of your server nor the database queries and especially you can not estimate the traffic

While testing EC2 for one month non-stop 24/7

My bill came out to be $75 … but I’m sure once I start using lots of bandwidth that will easily jump up past $150 … max $200.

But that fine because with Godaddy I’m paying $200 for a dedicated server monthly when I don’t even use $200 worth of service every month.

In my situation Amazon’s service is great because I’m only paying for what I use.

thx! thats what i wanted to hear. its a little scary to put a cc down on something and not know what itll cost even in a ballpark range.

and does ec2 require you to also you amazon s3 service? it seems like it does but isnt clear…

right now i have a shared hosting plan on host monster and have recently looked into a dedicated server i can run root on and its expensive… this seems like a nice option.

do they charge you after 30 days? im wondering if i sign up now with my cc when i will receive my first bill. the first month or so would be internal testing so itd be very limited bandwidth etc.

It is part of the whole AWS thing. It may not be exactly what you are looking for – so my advice is not to cancel anything you have going on just yet. Sign up for EC2 and play with some of their ready-to-go images. If you like it, and it clicks with you, you can look at how to make it meet more of your needs. If it doesn’t work out, you’ll be out a couple of dollars, max.

Back to the original post – yeah, this is a really good thing. Unity + SFS + EC2 has to be the lowest cost of entry for prototyping something and being able to scale it up through testing.

Semi-related, I would also be really interested in seeing how viable it is to use CloudFront for serving static assets for the game.

yea i just dont really understand EXACTLY what this amazon stuff is. maybe i should call them… like is ec2 an actual dedicated server or a disk image running on a server that i have root access to?

the amazon s3 seems easier to understand… it seems as though its just remote storage, and priced pretty well… they seem to charge by posts / gets instead of by bandwidth? and the docs on amazon says you add a ec2 image to your s3 so it seems s3 is required? even if it isnt it might be a good option.

if somebody could write a quick jist of the amazon crap id be very grateful.

ec2 is neither
Its a cloud computing system.

drunknbass … I’m not server savvy or anything but the simplest way for me to describe ec2 is…

It’s an expandable dedicated system in the clouds… :shock:

yeah… sounds crazy… but think about the service name ec2 = Elastic Compute Cloud. The way I see it (and I may be wrong) … it’s like having a dedicated server with no default limits… and its pay as you go.

You can remote connect to your ec2 instance just like any other server… you can install as many instances as you want. So no more buying another hosting account from your hosting provider just because you need a linux system to test on. Just run a linux instance and bam… terminate the instance when you want… only paying for what you used…

So lets say you just used 10 hours… for a base linux system that’s just $1.00!!! Not bad if you ask me.

To tie this back into the original thread – there is an AMI (which is an image used by EC2) with SmartFoxServer PRO running on Linux that is ready to go. So, that addresses an easy way to get it running – you just load up that instance. I personally haven’t used their image – but I’ve used SmartFoxServer and EC2 independently. My guess is that addressing clustering still needs to be done by building your own image. That is, ideally, how you would set things up – so that scale based on need more-or-less real time and not be manually launching new images and trying to get everything working together. SFS has a white paper on this.

Why this is cool here is that SFS has been made to play extremely well with Unity thanks to Thomas’s hard work.

Maybe this will help?

Would Unity and Smartfox also be compatible with other cloud computing solutions? Like Mosso?

So, Unity is just the client in this case – it isn’t really part of the equation. SmartFoxServer is pretty flexible with regards to what it can run on. You couldn’t use the AMI for a non-Amazon service (so it isn’t just there waiting for you) but there is no reason why it shouldn’t work with other similar hosting options as well.

To really take advantage of the whole game back-end as a service thing, you will want something like Terracotta running with SFS – they have a white paper on their web site with details. One of the really nice things is that a Terracotta cluster runs beautifully on EC2. In fact, if I recall, one of the Terracotta guys blogged about running on EC2 as soon as they let him in the original beta.

SmartFoxServer being a packaged java application server makes it super flexible in deployment platforms as Charles already mentioned. Anywhere you can get java to run, you can theoretically get a SFS server running. That should cover 99%+ of the server platforms out there in the wild.

Now that doesnt necessarily mean that its cloud compatible with every cloud system out there. But Charles already summed it up - Terracotta being the key here.

I have to say I’m pretty excited about SFS as well, and Thomas really did a great job of making SFS “Just work” with Unity. Obviously, SFS is not for everyone: It doesn’t “solve MMO” just like that, but it does do a super job of solving a particular subset of MMO style games. I have my own theories about where the limits are, but will need to measure some more before I know.

Its a super way to get started on an MMO though.

this may seem like a really basic question for all you gurus. But I was wondering…Does anyone have an architecture drawing, explaining how SmartFox Unity and the Amazon cloud would work together.

I know it’s a simplistic request, but it would really help.

Thanks.

I dont know of any - but try to poke the SFS guys on the SFS forums about it! I’m pretty sure there are more guys over there that have had the same need.

And link back if you get it from someone :slight_smile:

Mosso doesn’t let you run server-side software (aside from php, asp.net and mysql). SMS is a java aplicaiton you need to install, configure and run.

EC2 and Mosso are very different clouds. EC2 is basically a very large bank of Xen virtual machines; when you turn on an “instance” you are booting a disk image (called an AMI) into a Xen virtual machine. You can then ssh into your virtual machine and apt-get whatever, but there are lots of pre-built AMIs with various software already installed, so often you won’t need to do anything but configure. You can build your own AMIs and store them on S3, and you can have persistent storage for your instances on S3 as well. You have to manage all of this through command line tools. (Huge hint – there’s a firefox plugin that lets you do everything through a GUI. It’s an absolute must-have.) Command-line tools means there’s an API, so you can build your own controls to start and stop instances (look at http://tarzan-aws.com/).

Mosso’s cloud is much simpler – a large bank of web servers (some linux, some windows) in front of a very large SAN, and behind a smart load balancer that knows how to direct the .php stuff to linux servers and .aspx stuff to Windows servers. You store your files on the SAN (via FTP). You have to use Mosso’s name servers, because that’s where the real magic happens. There’s no API because there’s nothing to manage; web requests go in, data goes out.

I use both, but for different things. Mosso is my fantastically-scaling never-need-to-think-about web server. EC2 is my personal playground for when I’d like to have 50 servers for some task, like a large video encoding batch, or when I’ve got thousands of live users to stream video to.

You can handle thousands of live SMS users on a single EC2 instance. (I’ve done over a thousand concurrent live chat and video streams on a single EC2 “large” instance, running a Wowza Pro AMI.) I wouldn’t worry about solving the > 1000 concurrent users problem until you’ve got a working game thats delivering >100 concurrent users.

Scaling EC2 is no different than scaling a bunch of servers in your own rack. After all, they’re just a bunch of (virtual) servers; you still need to do handle the hard stuff, like synchronization of data between servers. Terracotta is a solution for this (for Java-based server apps only). Terracotta handles synchronizing objects and data structures of java-based apps between servers. I’ve read about it working for SMS and Red5, and it seems to be the real deal, although I’ve never tried it myself.

You could use Mosso as a Unity server if you polled a web-based API for updates, and stored the data in a MySQL backend. In fact, Mosso would be perfect for that. But most homemade MMOs I’ve heard of use socket servers (or even UDP, which you’ll never get from Mosso) for the quickest update times.

Mosso is 100 per month. I'm trying to find my Amazon bill for that large event... I can't find it, but as I recall it was super cheap. (A "small" server instance is .10 per hour the server runs. Run it 24x7 for a month and your charge is $72, not including bandwidth charges. You can play with numbers here: http://calculator.s3.amazonaws.com/calc5.html)

Also, Mosso now owns SliceHost, which is basically the same business as EC2 (virtual machines of various sizes) and the pricing is better. They don’t have all the nifty pre-built AMIs, I don’t know if there is an API, and I don’t know how large their infrastructure is, but it’s an option worth knowing about.

At it simplest, you have [EC2 server running SMS] ↔ [Unity client]. Just a server you turned on at EC2 running SMS, and the Unity client connects to it.

Once you put Terracotta in the mix, I assume you’d have as many SMS servers as you’d like, plus another server instance that acts as a load-balancer. (If you so something simple like round-robin through a list of running instances via PHP, you could avoid this.)

Also, all you potential MMO guys take note, there has been one time I know of when Amazon shut down all of the EC2 instances briefly. But that’s better uptime than the datacenter at one wilshire, now that I think about it.