Jump to content
  • Advertisement
Sign in to follow this  
Scouting Ninja

Could I use a raspberry pi as a server for a mobile game.

Recommended Posts

So starting a new mobile game and this time I want to add a proper leader board and allow players to retrieve profiles. For my first game I used Facebook to hold score, however the one score per player limit and the fact that you can only see the score of friends are annoying.

So now I wan my own server to deal with it except servers are expensive and I only need to store int and a copy of the Unity save.I have been thinking about getting my self a raspberry pi and turning it into a server for the mobile game, then I could also use it for my other mobile games if I want.

1.) Can I even use a raspberry pi as a server?

if I can

2.) How hard would it be and how long would it take more or less? (Assume I know nothing of networking.)

3.)What kind of maintenance am I looking at? I notice the rasberry doesn't have a cover or anything. It would have to run day in and out.

if I can't

4.) What are my other options?

I notice free server sites often forbid game hosting and only data storage, I think because then no one sees the adverts these sites use.

I really don't need much. Based on my projections from my other mobile games I think I am going to get around 500 - 800 players for about a month before it rapidly drops down. So I only need to store around 2000 player's data. Having my own server would make it easy to create more complex mobile games as I advance.

 

I am doing this for the experience so I don't mind if it's difficult or comes with some expense, I just don't want to spend thousands on this.

Share this post


Link to post
Share on other sites
Advertisement

The pi works as a great server for personal use, depending on what exactly you need it for. but if your expecting large volumes of people to play your game, the pi will most definitely not cut it. You could certainly start out with it though, and upgrade later. I have a couple pi's set up as servers at my house, ones even hosting a site (not a public site though)

Share this post


Link to post
Share on other sites
24 minutes ago, iedoc said:

but if your expecting large volumes of people to play your game, the pi will most definitely not cut it.

Lucky I am not expecting much. I think that it's going to take a long while before my games get decent downloads.

Thanks for letting me know it's possible.

Share this post


Link to post
Share on other sites
3 hours ago, Scouting Ninja said:

1.) Can I even use a raspberry pi as a server?

You can turn any computer to a server.

 

3 hours ago, Scouting Ninja said:

2.) How hard would it be and how long would it take more or less? (Assume I know nothing of networking.)

3.)What kind of maintenance am I looking at? I notice the rasberry doesn't have a cover or anything. It would have to run day in and out.

Hosting your own server (raspberry pi or not) involves dealing with making sure people from outside can access that box sitting under your desk. You'd most likely need to open up a port on your router. Some say it was that easy, but some others have said that they also need to call their cable provider to let incoming traffic into their home router. YMMV.

There exists tools like ngrok to let you tunnel in without having to deal with all above, but they may have certain limitations on the free version.

Maintaining a home server is not just making sure it has a cover. It is to also make sure it keeps on running, and your server app is not crashing under any condition. Power outages, network loss, DDoS are some of the things that you need to worry about.

Edited by alnite
grams

Share this post


Link to post
Share on other sites
1 hour ago, alnite said:

Maintaining a home server is not just making sure it has a cover. It is to also make sure it keeps on running, and your server app is not crashing under any condition. Power outages, network loss, DDoS are some of the things that you need to worry about.

Thank you for this, it's exactly the kind of information I need. In the past I hired a server and of course these things are easy to miss when other take care of them.

1 hour ago, alnite said:

You'd most likely need to open up a port on your router. Some say it was that easy, but some others have said that they also need to call their cable provider to let incoming traffic into their home router. YMMV.

Good to know. I remembered that I had problems with incoming traffic when I set up my render farm, so chances are I will need to look into this.

1 hour ago, alnite said:

You can turn any computer to a server.

I wasn't 100% sure the raspberry was a full computer. I remember when it first launched it was marketed as a platform for kids to learn python. Yet I think I somewhere seen someone mention that they used it as a server and I just wanted to double check.

I don't want to use my other computers as servers because it could be a risk and I need them for work. With a raspberry if something happens the cost of fixing it should remain low; unless my house burns down.:)

 

I have been reading up on the raspberry and it does look like a good option for a starter server, so I am going ahead with it.

Share this post


Link to post
Share on other sites
2 hours ago, Scouting Ninja said:

I don't want to use my other computers as servers because it could be a risk and I need them for work.

You're right that your server should not also be a workstation, for a whole bunch of reasons.  Consider though that as soon as you open the ports and invite connections into machines in your home, there's going to be some amount of risk involved.  What you could do is get one of those VPS-style hosting services like Digital Ocean or Linode or something and deploy your server on one of those.  You won't be inviting connections into your home network, don't have to worry about weird port forwarding or asking for a static IP from your home internet provider, etc.- but they do cost about $5/month minimum to keep them running.

Edit:  Also, consider that security on a server like that is hard to get right if you don't already know what you're doing- so offloading that task to a machine with nothing else of value on it would be a good idea.

Edited by trjh2k2

Share this post


Link to post
Share on other sites

Yeah your home router/ISP is a more troublesome issue than whether your server is a Pi or a PC :)

Many ISPs actually have a clause in the fine print that hosting any kind of service is not allowed ("please upgrade to a business plan"), so be aware that you might be sneakily doing something that could get you cut off. Likewise most ISPs will change your IP every time your router reboots, which is very bad when trying to maintain a stable server.

You can get free trials of virtual server hosting on Amazon or Azure. If you don't expect longevity you might be done by the time the trial runs out. Alternatively, you can get a virtual server with similar performance to a Pi but in a datacenter with a 1Gbps internet connection for under $5/month.. 

Share this post


Link to post
Share on other sites

Thanks for the advice. I contacted my service provider to check if I would be allowed to host, I explained to them what I needed and found out that under my current contract I would NOT have been allowed to host the server.

It turns out that switching to a contract where I can host costs less than $1 extra and gives me 2GB cloud storage with limited bandwith. I also had to remove a restriction on my modem that they guided me APN restriction?

They reassured me it isn't only for websites, a concern I had when they provided me with website building tools. I don't know how I feel about it.

 

On the one hand I now have every thing I need to keep score and store profiles, with good options to upgrade, don't need to maintain and it all costs less than a single dollar.

On the other hand I still have no idea how any of this works. They gave me software and some example code(Java and C++) to show how I would store data. That part works I made a C++ program to test.

 

I wonder if I should now still get the raspberry just to learn networking, then at the same time would I ever need to?

Share this post


Link to post
Share on other sites

Yes, a Raspberry Pi can be a "server" because a "server" is just a computing machine that responds to requests from other nodes on the internet according to some rules that you decide. A Raspberry Pi 1 is probably about the same compute power as the server computers that ran the game EverQuest, one of the first really big MMOs (back in 2000 or so.) That being said, a Raspberry Pi does not allow you to hook up very durable media -- the compact flash is not designed for constant reading/writing over long times. Perhaps a hard disk on USB could solve that?

What's harder is to figure out how those other machines would find your server. If you have a typical home Internet service, you have a single IP address, and that address goes to your router. You'd then have to port forward from the router to your Raspberry Pi. You'd then have to register a domain name, and make it map to your IP address. And, when your ISP changes your home IP address (which happens automatically every so often without warning or notice,) you'd have to update the DNS to map to the new address, and wait for DNS caching to expire, so some users couldn't find your server for a while.

This is why servers live in data centers. They can have a fixed IP address, and a squirrel chewing on your internet wire won't knock you offline, and a heatwave won't make your home computer suddenly overheat while you're not even there to do anything about it.

Using a web host of some sort is much easier. Even better is something like a virtual private server -- be it Linode ($10/month,) interserver ($6/month,) or Amazon Lightsail ($5/month and up, plus networking fees.) Of course, as your server needs grow, you will need to pay more for the server hosting.

 

So, your web hosting provider has a plan that lets you "host" somehow? It's hard to tell exactly what that means. It might be a small container / virtual machine. At that point, you could build your own service using whatever tech you want (C++, node.js, golang, python, erlang, C#, Java, Haskell, PHP, ...) and have your apps talk to your service. You still need to register a domain name, and make "api.yourgamename.com" or somesuch point to that server's IP.

Or you can use Game Center on iOS and Google Play Services on Android. Sounds simpler :-)

Share this post


Link to post
Share on other sites
11 hours ago, Scouting Ninja said:

I wonder if I should now still get the raspberry just to learn networking, then at the same time would I ever need to?

If you're looking to get into server development and management, get yourself VirtualBox (or VMWare) and set up local test servers as virtual devices on a local workstation in a virtual network.  You can play with everything you need that way, with backups (in case you mess up) and easy restarts (in case you mess up).  Study up on using Docker to wrap and provide your services, and that way you can build and test on your local  workstation-encapsulated server network and then migrate (publish) to your live server, with minimal risk and without change.

If you want to get a Pi, get a Pi.  You don't need a Pi to do any server development.  You can even run Docker on a Pi if you're serious about using one as a server.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Similar Content

    • By Alexander_Vovk
      Hello Guys!
      Please share your experience, where is it better to find sales manager  specialists for indie team of 6 + people(remotely)?
      Maybe someone has a good experience of cooperation with finding projects through sale managers(USA and Canada)?
      Thank you
      Best Regards
      Alex Vovk
      Co-Founder of Sixteen Squares
      Alexander_Vovk@outlook.com
       
    • By RoKabium Games
      Been a bit quiet recently, but we've been busy bug fixing and tweaking things... Now we have lots more 'Particle effects' in the game, specifically here the Flamethrower and Enemy attacks!
    • By JoshuaFraser
      Hi and thanks for reading, I have an issue with this reactive crosshair script, everything works fine until I start changing the offset. Give the script a go and you will see what I mean, when I do SetOffset(0f); it doesnt always set back to the origional state, if anyone can spot a fix I'd be super appreciative!
      using System.Collections; using System.Collections.Generic; using UnityEngine; public class ReactiveCrosshair : MonoBehaviour { [SerializeField] GameObject c_limb_prefab; private float center_offset = 0f; private float current_offset = 0f; private float max_offset = .5f; private int number_of_limbs = 4; private float limb_length = .05f; private float limb_width = .005f; private List<GameObject> c_limbs = new List<GameObject>(); public void SetupCrosshair(){ for (int i = 0; i < number_of_limbs; i++) { GameObject line_go = (GameObject)Instantiate (c_limb_prefab); line_go.transform.SetParent (this.transform); Vector3 limb_pos = new Vector3 (0f,0f,0f); //line_go.transform.position = limb_pos; line_go.transform.localPosition = limb_pos; LineRenderer line = line_go.GetComponent<LineRenderer>(); line.startWidth = limb_width; line.positionCount = 2; line.SetPosition (0, line_go.transform.localPosition + new Vector3(center_offset, 0f, 0f)); line.SetPosition (1, line_go.transform.localPosition + new Vector3(center_offset + limb_length, 0f, 0f)); line.useWorldSpace = false; c_limbs.Add(line_go.gameObject); } if (c_limbs != null) { OrientLimbs (); SetOffset (0f); } } public void OrientLimbs(){ for (int i = 0; i < c_limbs.Count; i++) { float rotation_step = 360f / (float)c_limbs.Count; c_limbs [i].transform.RotateAround (c_limbs[i].transform.position, c_limbs[i].transform.forward, 90f + (rotation_step * (float)i)); } } public void SetOffset(float _current_spread){ float offset = Mathf.Lerp (0f, max_offset, _current_spread); for (int i = 0; i < number_of_limbs; i++) { if (offset > current_offset) { Vector3 pos = c_limbs [i].transform.position + (c_limbs [i].transform.TransformDirection (Vector3.right) * offset); c_limbs [i].transform.position = pos; } if (offset < current_offset) { Vector3 pos = c_limbs [i].transform.position - (c_limbs [i].transform.TransformDirection (Vector3.right) * offset); c_limbs [i].transform.position = pos; } } Debug.Log ("SetOffset() offset: " + offset.ToString () + " _current_spread: " + _current_spread.ToString() + " localPos: " + c_limbs[1].transform.localPosition); current_offset = offset; } }  
    • By Erik Nivala
      So, as the title says i am trying to figure out a good way sync all that information with other players in Unity. My problem is that i can't come up with a good solution since i am used to creating classes for everything e.g. attachments are its own class and then the weapon would save a reference to that attachment. But since you can't send custom classes over [Command] & [ClientRPC] i am a little stuck. A solution for this would be giving each attachment for a slot a unique ID and then passing the ID to other player but i feel like that is very error prone if other ppl add a new attachment or the IDs get mixed up.
      Is there a "standard" way that this is usually done that i am missing?
      I am fairly new to programming so any help is appreciated!
    • By MintyLyton
      I'm looking for any team / people that need a programmer for their project. I'm looking to expand my portfolio which you can see Here. I'm more experienced with Unity but I can spend the time to learn new Engines if that's your preference. I have worked on Unreal Engine 4 before but I might take some time to re-learn it, if the project requires it. Feel free to DM here or use the contact info on my website. 
    • By ethancodes
      I'm working on a system for my game that will allow the player to stack pick ups in a queue. As one pick up expires, the next automatically activates. I'm having an issue though where if I pick up the first one, it activates fine, but if i pick up a second directly after it, it overrides the first one, activates the second one, and then once it has run it's course, everything goes back to normal gameplay, no first pick up. I'm not sure why this is happening. Hopefully someone can spot what I'm doing wrong in my code.
      Here is the code for the pick up manager:
      // Update is called once per frame void Update () { if (pickUpQueue.Count != 0 && !pickUpActive) { pickUpActive = true; pickUpQueue[0].ActivatePickUp(); } DeactivatePickUp(); } void DeactivatePickUp () { if (pickUpQueue.Count != 0 && pickUpActive) { Destroy (pickUpQueue [0]); pickUpQueue.RemoveAt (0); pickUpActive = false; } } And here is the PickUp:
      public override void ActivatePickUp () { ball.GetComponent<Ball>().Speed = 2.0f; //increase ball speed... ball.GetComponent<Ball>().StartCoroutine(timer); //...set time that power up is active }  
      There is also a Base Pick Up:
      public void OnCollisionEnter2D (Collision2D collision) { Vector2 tweak = new Vector2 (Random.Range(0f, 0.2f),Random.Range(0f, 0.2f)); this.gameObject.GetComponent<Rigidbody2D>().velocity += tweak; //if the pickup makes contact with the paddle or ball.... if (collision.gameObject.tag == "Paddle" || collision.gameObject.tag == "Ball") { GameObject.FindObjectOfType<GameManager>().GetComponent<PickUpManager>().pickUpQueue.Add(this); Destroy(gameObject); //...and finally destroy power up object } } As a side note, I am trying to find a solution to this that will work for all of my pickups. Some pickups are ammo based, some are timed. 
    • By D34DPOOL
      Edit Your Profile D34DPOOL 0 Threads 0 Updates 0 Messages Network Mod DB GameFront Sign Out Add jobEdit jobDeleteC# Programmer for a Unity FPS at Anywhere   Programmers located Anywhere.
      Posted by D34DPOOL on May 20th, 2018
      Hello, my name is Mason, and I've been working on a Quake style arena shooter about destroying boxes on and off for about a year now. I have a proof of concept with all of the basic features, but as an artist with little programming skill I've reached the end of my abilities as a programmer haha. I need someone to help fix bugs, optomize code, and to implent new features into the game. As a programmer you will have creative freedom to suggest new features and modes to add into the game if you choose to, I'm usually very open to suggestions :).
      What is required:
      Skill using C#
      Experience with Unity
      Experience using UNET (since it is a multiplayer game), or the effort and ability to learn it
      Compensation:
      Since the game currently has no funding, we can split whatever revenue the game makes in the future. However if you would perfer I can create 2D and/or 3D assets for whatever you need in return for your time and work.
      It's a very open and chill enviornment, where you'll have relative creative freedom. I hope you are interested in joining the team, and have a good day!
       
      To apply email me at mangemason@yahoo.com
    • By davejones
      Is there a way to automatically change the start position of an animation? I have a bunch of animations set up on 3D models in unity. The issue is that I need to move the 3D models, however when I do so the animation start positions are not updated and I have to do it manually.

      Changing the transform of key frames is time consuming with the amount of animations I have, so I was wondering if there was a way to do it automatically?
    • By Ibragim Vykov
      Hi, everyone! I'm a self-taught indie developer. After two years of learning programming and gamedev, I finally released my first game. It's a hardcore arcade with simple one-tap control. Check it out please, it would mean a lot to me. And also I'd be very interested to hear your feedback.
      Get it on Google Play: 
      https://play.google.com/store/apps/details?id=com.ibragames.circlevsspikes 
      Official trailer:
      https://www.youtube.com/watch?v=oTbQHaD_nWo

    • By MoreLion
      hey all! We are looking for members for our Unity horror game! 
      Here’s the story:
      After a deadly virus plunges the world into chaos killing 85% of the human population there are now what they call “zones” these zones are watched very closely by the surviving government, people are checked every day for the virus, even if you touch the spit or any human waste or fluids of the victim who is infected, you will die. But one day, people in the west zone start to go missing, 1 woman goes outside the walls to uncover the mystery, is there more to the virus than meets the eye?, That is where your story starts.
      This game is not a long development game, I have loads other game ideas,
      I will also allow you to have a bit of creative freedom if you wish to add or share a idea!
      And no, it’s not a zombie game lol I feel like zombie games are too generic, in this game you will encounter terrifying beasts!
      There is some concept art one of our concept artists have made
      If interested email liondude12@gmail.com
  • Advertisement
  • Popular Now

  • Forum Statistics

    • Total Topics
      631395
    • Total Posts
      2999780
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!