<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Unity.Multiplayer%2Farticles%2Fhosting%2Faws-ec2</id>
	<title>Unity.Multiplayer/articles/hosting/aws-ec2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Unity.Multiplayer%2Farticles%2Fhosting%2Faws-ec2"/>
	<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/hosting/aws-ec2&amp;action=history"/>
	<updated>2026-12-05T13:25:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.3</generator>
	<entry>
		<id>https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/hosting/aws-ec2&amp;diff=912&amp;oldid=prev</id>
		<title>Docs Sync: md2wiki: sync from MindAttic.Docs</title>
		<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/hosting/aws-ec2&amp;diff=912&amp;oldid=prev"/>
		<updated>2026-11-29T20:36:41Z</updated>

		<summary type="html">&lt;p&gt;md2wiki: sync from MindAttic.Docs&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Hosting on AWS EC2 (AwsEc2) =&lt;br /&gt;
&lt;br /&gt;
A big-cloud profile (UM-T27): &amp;lt;code&amp;gt;mp-host&amp;lt;/code&amp;gt; creates a VPC security group it owns, then an EC2 instance running the same Docker image + rendezvous side-car compose stack as the GenericVps profile, booted by a cloud-init document passed as the instance&amp;#039;s &amp;lt;code&amp;gt;UserData&amp;lt;/code&amp;gt;. Unlike GenericVps, there is no bring-your-own box: &amp;lt;code&amp;gt;mp-host&amp;lt;/code&amp;gt; creates and destroys the instance and its security group itself.&lt;br /&gt;
&lt;br /&gt;
== What &amp;lt;code&amp;gt;mp-host deploy&amp;lt;/code&amp;gt; does here ==&lt;br /&gt;
&lt;br /&gt;
# Builds (or reads an already-built) &amp;lt;strong&amp;gt;GenericVps-profile&amp;lt;/strong&amp;gt; server package and its Docker image (EC2 instances run the exact same compose stack as a plain VPS -- &amp;lt;code&amp;gt;AwsEc2&amp;lt;/code&amp;gt; only changes how the box and its firewall are created, not the shape of the package Unity builds), then pushes the image to GHCR.&lt;br /&gt;
# Calls EC2&amp;#039;s &amp;lt;code&amp;gt;CreateSecurityGroup&amp;lt;/code&amp;gt; to make an empty security group named &amp;lt;code&amp;gt;mp-host-&amp;amp;lt;server name&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Renders the compose file + bootstrap script (the same ones GenericVps uploads over SSH) into a &amp;lt;code&amp;gt;#cloud-config&amp;lt;/code&amp;gt; document and launches the instance (&amp;lt;code&amp;gt;RunInstances&amp;lt;/code&amp;gt;) with it as &amp;lt;code&amp;gt;UserData&amp;lt;/code&amp;gt;, your chosen AMI and instance type, and the new security group attached.&lt;br /&gt;
# Calls &amp;lt;code&amp;gt;AuthorizeSecurityGroupIngress&amp;lt;/code&amp;gt; to open SSH (22/tcp, the only way &amp;lt;code&amp;gt;mp-host&amp;lt;/code&amp;gt; can reach the box afterwards), the rendezvous port (8080/tcp) and your declared game port.&lt;br /&gt;
# Polls &amp;lt;code&amp;gt;DescribeInstances&amp;lt;/code&amp;gt; over SSH for &amp;lt;code&amp;gt;GET http&amp;amp;#58;//127.0.0.1:&amp;amp;lt;healthPort&amp;gt;/healthz&amp;lt;/code&amp;gt; once the instance has a public IP, exactly like GenericVps.&lt;br /&gt;
# Watches &amp;lt;code&amp;gt;docker compose logs game&amp;lt;/code&amp;gt; over SSH for the join-code line and prints it.&lt;br /&gt;
&lt;br /&gt;
== Before you deploy ==&lt;br /&gt;
&lt;br /&gt;
You need an AWS account, an EC2 key pair already created in the region you&amp;#039;ll deploy to, and the matching private key locally. AMI ids are region-specific, so &amp;lt;code&amp;gt;mp-host&amp;lt;/code&amp;gt; does not guess one -- look up a current Ubuntu 22.04 LTS AMI id for your region (the [https://cloud-images.ubuntu.com/locator/ec2/ Canonical AMI locator]) before your first deploy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code&amp;quot;&amp;gt;mp-host credentials set-aws --access-key-id &amp;amp;lt;AKIA...&amp;gt; --secret-access-key &amp;amp;lt;secret&amp;gt; --region us-east-1&lt;br /&gt;
mp-host credentials set-ghcr --username &amp;amp;lt;github-username&amp;gt; --token &amp;amp;lt;PAT with write:packages&amp;gt;&lt;br /&gt;
mp-host credentials set-cloud-options --profile AwsEc2 --name prod-ec2 \&lt;br /&gt;
  --opt amiId=ami-0abcdef1234567890 --opt keyName=my-ec2-keypair \&lt;br /&gt;
  --opt sshUser=ubuntu --opt sshKeyPath=C:\Users\me\.ssh\my-ec2-keypair.pem&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The AWS credential is shared with the &amp;lt;code&amp;gt;AwsLightsail&amp;lt;/code&amp;gt; profile; the launch options above are per server name and are what &amp;lt;code&amp;gt;ProviderConnection.ProviderOptions&amp;lt;/code&amp;gt; carries into &amp;lt;code&amp;gt;Ec2Provisioner&amp;lt;/code&amp;gt; -- see its class doc for every recognised key (&amp;lt;code&amp;gt;vpcId&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;subnetId&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;instanceType&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;rendezvousImage&amp;lt;/code&amp;gt; are all optional).&lt;br /&gt;
&lt;br /&gt;
Then deploy:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code&amp;quot;&amp;gt;mp-host deploy --profile AwsEc2 --name prod-ec2 --package ./build/GenericVps \&lt;br /&gt;
  --image myorg/mygame --tag v1 --region us-east-1 --size t3.micro \&lt;br /&gt;
  --rendezvous-url https&amp;amp;#58;//rendezvous.example.com \&lt;br /&gt;
  --public-address prod-ec2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add &amp;lt;code&amp;gt;--dry-run&amp;lt;/code&amp;gt; first to see every EC2 API call (&amp;lt;code&amp;gt;CreateSecurityGroup&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;RunInstances&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;AuthorizeSecurityGroupIngress&amp;lt;/code&amp;gt;, ...) mp-host would make, without spending anything.&lt;br /&gt;
&lt;br /&gt;
== Open ports ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Port&lt;br /&gt;
! Protocol&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| your game port&lt;br /&gt;
| UDP (or TCP for WebSocket)&lt;br /&gt;
| Players connect here.&lt;br /&gt;
|-&lt;br /&gt;
| 8080&lt;br /&gt;
| TCP&lt;br /&gt;
| The rendezvous service.&lt;br /&gt;
|-&lt;br /&gt;
| 22&lt;br /&gt;
| TCP&lt;br /&gt;
| SSH -- the only way mp-host reaches the box after boot; mp-host opens it to &amp;lt;code&amp;gt;0.0.0.0/0&amp;lt;/code&amp;gt; by default. Tighten the security group yourself afterwards if you want SSH restricted to your own IP.&lt;br /&gt;
|-&lt;br /&gt;
| health port&lt;br /&gt;
| TCP, bound to 127.0.0.1&lt;br /&gt;
| Not reachable from the internet by design.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Updating and tearing down ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;mp-host update&amp;lt;/code&amp;gt; re-renders the compose file and restarts it in place over SSH -- the instance itself persists across an image swap, exactly like GenericVps&amp;#039;s rolling restart; there is no instance replacement the way RunPod&amp;#039;s pod-swap works. &amp;lt;code&amp;gt;mp-host destroy ... --yes&amp;lt;/code&amp;gt; stops the compose stack, terminates the instance, then deletes the security group (EC2 sometimes needs a few seconds after termination before the group can be deleted; mp-host warns rather than fails if that happens -- delete it yourself once termination finishes).&lt;br /&gt;
&lt;br /&gt;
== Cost and data-transfer notes ==&lt;br /&gt;
&lt;br /&gt;
EC2 bills the instance by the hour/second &amp;lt;strong&amp;gt;and&amp;lt;/strong&amp;gt; its internet egress separately -- the game traffic flowing out to every connected player counts against the second meter. As a rule of thumb: a small-scale real-time game server sending each player roughly 20 KB/s (plan for your own game&amp;#039;s actual send rate -- this varies a lot by genre and tick rate) works out to about &amp;lt;strong&amp;gt;0.07 GB per player-hour&amp;lt;/strong&amp;gt;. At EC2&amp;#039;s typical US-region on-demand egress price of roughly $0.09/GB (verify your region&amp;#039;s current price against the [https://aws.amazon.com/ec2/pricing/on-demand/ EC2 pricing page] -- this changes and the first 100 GB/month account-wide is often free), that&amp;#039;s on the order of &amp;lt;strong&amp;gt;$0.006 per player-hour&amp;lt;/strong&amp;gt; in data transfer alone, on top of the instance&amp;#039;s own hourly rate (a &amp;lt;code&amp;gt;t3.micro&amp;lt;/code&amp;gt; is a reasonable default for a small lobby). Multiply by your expected concurrent players and hours of operation to budget a month, and remember &amp;lt;code&amp;gt;mp-host destroy&amp;lt;/code&amp;gt; is the cheapest way to make sure nothing keeps billing after a test.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-crumb&amp;quot;&amp;gt;Part of [[Unity.Multiplayer]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-source&amp;quot;&amp;gt;From [https://github.com/mindattic/Unity.Multiplayer/blob/main/docs/articles/hosting/aws-ec2.md Unity.Multiplayer/docs/articles/hosting/aws-ec2.md] via MindAttic.Docs; synced automatically, so edit the repo, not this page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unity.Multiplayer]]&lt;/div&gt;</summary>
		<author><name>Docs Sync</name></author>
	</entry>
</feed>