Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I developed a turn based game for Android, and now I want to add multiplayer gaming. I don't want to use providers like "skiller", I would like to develop my own server.
I don't have a dedicated server, but I have a php hosting with "1 and 1". Would be a good idea to use this hosting like a game server? My idea is that my Android game polls server every X seconds waiting for opponent move.
What do you think about it?
I have looked into using them for hosting and I have heard great things about their support. BUT unless your using a dedicated server that they offer (instead of the base level shared hosting service) you probably won't have the resources available to support a gaming server.
If you can handle doing the server config yourself or are good with detailed instructions on how to set one up then I highly recommend using the $20 a month linode.com base plan. I am using it for site hosting and it makes a huge difference in terms of performance and flexibility. Also I have seen some performance benchmark comparisons done between it, slicehost, rackspace, and Amazon S3 and it blew all of them (especially Amazon) out of the water. The benchmark is 2 or 3 years old, but it is still rather telling.
Linode will let you do ANYTHING you want within the bounds of the law with the server. So if you want to host an adult site they won't have a problem with it. They will probably have a problem with setting up a spam server or some shady things like that. But they are cool with everything else it seems. Plus they are probably the most affordable option out there.
I would add that you may look into the technology behind APE servers (AJAX Push Engine). Its a high efficiency chat system that works with pretty much any server-end language and front-end.
http://www.ape-project.org/
this is how I would do it, since your game is asking the server for pull request lets skip one step. Thats asking the MySQL server. So here is the way I would do it.
From what it sounds like its a html5 game meaning that you could set cookies, on the users phone. I would have a cookie or even a javascript var that then stores a JSON or ARRAY string. from this you would be able to push 1 or 0 to the PHP script that hopefully would be able to send it to the user or store it as a .txt files it is known that fetching data from mysql is slower and if you have 400 users all doing it at 5second intervals you will bring down most shared servers, They are just not strong enough to do what you want.
If your budget is small may I suggest you look this option. I cant really think of away you can do this without storing the data somewhere.
You should not listen to programming language specific arguments, most of the time they are personal preferences. What you want to do is of course possible with PHP. You can do good and bad programming in every language. For a turn based game PHP is totally sufficient, if you know how to use it. Use the programming language you are most comfortable with, and you will be just fine.
What is more important: You want your game to be successful, 1und1 is not capable of handling a way of "success", because of its localized and not scalable on demand nature. If you want to gain money or spread, you really should not fear to invest some low bucks and go for Amazons infrastructure. You will have to learn a little, but it is definitely worth it.
Most IDEs (Zend Studio, PHP Storm, ...) even have good integration already. A shared hoster or a localized storage hoster is not what you want, because if your app gets famous they simply will not be able to handle global demand. And you will have security problems. If you really expect your game to be successful, even a VPS will reach its limit almost immediately.
You can try to grow your game by using 1und1 first, and upon demand going to a better solution. But quite some games just died because the demand was much higher than expected. The worst thing about this is you have to think less euphoric but more realistic.
To sum it up: Just use the language you are most comfortable with, if you believe in your idea do not fear to invest little bucks to meet the global market, create your own protocol with as less data transfer as possible, and please poll more often than "x seconds", because a second waiting for the opponent feels like three days. And you are on your way.
Good progress! And post a link when you're done:)
You can use Firebase messaging service to implement the same. Further you have must one Web server (e.g. PHP).
Use your android code to send request to PHP file at web server.
From this web server you can send broadcast message in form of firebase Messaging which will deliver to all devices of your subscribed topic.
All android device those listen for this FCM can respond(depend on parameters set by your code).
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have developed an Application in PHP, the application has complete User Management System along with Dynamic form creation feature , Data import,export feature and many more. I am using Mysql as a database. When i was doing testing on that application, it was working perfectly fine. Now i have deployed this application on the customer side and almost 50-60 user are running this application, its been two month and now they are facing some problem. They said some time application respond very late , and some time it took so much time to respond. For example to use this application user need to login into the application , now some time login feature perfactly fine and user can easly and some time it took a lot of time to login. I personally look into this and face the same problem. Now i am confuse where is the actual problem.
My Applicaiotn
Network Speed
Sever
LargeData in SQL
How can i get any clue that where is the exact problem.
You're going to need to provide a LOT more information to get a decent answer. And in providing that data, you will almost certainly solve the problem...
In most database-driven applications, the database is the first place where performance issues arise, especially as the data scales. A system that works fine with just a few records in the database can grind to a halt when scaling up...
So the first thing I'd do is look at the database processes while people are using the system, and look for long-running queries. Optimize those queries, and rinse & repeat.
It may also be worth writing debug log statements around your database access logic so you can look at historical performance stats - this is useful if the client tells you that the system slowed down yesterday, but is running fine today.
If it isn't the database, you need to look at the PHP performance. You'll need a profiler (try XDebug) and look for bottlenecks in your PHP code.
If it's neither the database nor your PHP code, you may have a configuration problem with your web server software (Apache or whatever you're using). This is hard to debug - you'll need to trawl through the configuration files and look for limits (e.g. "MaxConnections").
If it's not those things, the network may be the problem. This is pretty rare - if the network can't support a web application, file sharing, email and video conferencing will all suffer too. Ask your client if this is the case. To prove or disprove, put a decent size file on your webserver (a 20MB MP3 file should do it) and test how long it takes to download it while the application is running slowly.
If it is the the problem with your application, try optimizing the code. This point becomes irrelevant as the code is not provided.
Try pinging the server and check the response time. If it is normal then there is no issue with the network.
Check the Server's H/W configuration(both application and mysql server) and if the H/W configuration of the server is low for the application to run, kindly upgrade.
THIS IS MOST LIKELY TO BE THE SOLUTION: If your mysql has a large amount of data, try indexing the database. For instance you had problem with logging in, so try to indexing the usernames in your "users" table.
To be frank the data provided in the question is insufficient to come up with a concrete solution.
If the speed of your application was correct when you deployed it initially, I suppose that the problem will be the database.
Is your database normalized? Do you have the correct indexes? You can try indexing all the columns that you use in the WHERE clausules.
But, as Abhay Pai said, the data provided is insufficient to solve this problem.
We have developed a web application for an office management, the plan is to provide a hosting server.
Therefor due to some circomstences an important part of our targeted portential clients, wouldn't want there work online on the web (even if many security measurment are to be implemented), so we offer a LAN installation for these clients.
This is causing a real headaches for the team, since we don't want someone with enought skills to access our sources code, since if they do, they can try and find a way to hack our online sytem.
So, the question is how can we protect our work from beeing accessible, and only allow its execution, obfusticating the PHP code is one way, but its not enough, while seaching I've come accross a way where we can make a Vitrual machine, but this is not the most optmal solution since it will require some hardware configuration (memory and other stuff)
Does anybody know a way out from our misery ? It would be wonderful if its a free solution, but if not, it can be okay with a cheap one :)
This is a FAQ here and the received wisdom is that you can't do anything. This makes sense if you think about it as ultimately there is nothing you can do to stop someone reading what their computer is doing. If your computer is going to run code, it must be in a computer-acceptable format which means that no matter how you try to hide it, it can be decoded and displayed as in order for your computer to understand it, it must meet certain inviolable standards which are published and well known.
You can make if difficult for people who would not know what to do with the code anyway, but anyone who could use your code will be able to get it if they want to.
Is your stuff so remarkable and innovative that you really think it is worth stealing?
For instance, it took me almost 10 minutes to work out how Google did it's nifty suggest thing and another 20 to replicate it. By SO standards that is extremely slow. I use the idea along with almost everyone else but I have never seen their code and it would be boring if they showed it.
Why not just bind users with a non-reverse-engineering contract? This, after all is how MS protects its IP. Windows is easy enough to copy if you want to. MS makes it worth paying for their product by providing updates only to licenced users. Perhaps you could do the same.
Ask yourself if it is REALLY necessary to have the code hosted locally. When did the internet last fail you? 3 years ago I experienced a major earthquake. No power, water or sewage for 2 weeks but the internet both wired and mobile kept working. My computer didn't as I had no power but 3g was just fine. The infrastructure is incredibly robust and there is really very little need for local data duplication. My experience has been that anything that knocks out the internet more than transiently is more than likely going to knock out any local solution too.
Finally, if your clients want a locally hosted solution, ask yourself if they are worth the trouble. The best way to help them to mature is to let them see what they are missing.
Caveat - I do actually duplicate some data on some local systems but this is a useful feature of backup - I allow clients a view of the backed up data in the event of catastrophic internet failure, but I don't allow them to modify the locally held data as it negates the 'one true record' principle which is why we use the cloud in the first place.
I'm working on a small private site for a group of 10 people. It's essentially a tiny social network just for us. We currently also use Windows Live Messenger for real-time chatting but we're looking to create an alternative since the MSN clients out there for Mac, Linux and smartphones do not support the recently added group features in MSN, which we use.
I've been reading up a little on push technology to see how I'd go about creating a web based chat room that suits our very limited needs. I gather that Apache is not really suited for long polling at all, and that using something like APE would be a better idea. However, we're running on a fairly cheap but very good shared host so we simply don't have the ability to install any server side software.
To my question.
Since we are, after all, just a handful of users, and most of the time only half of us will be online, is is likely that simple PHP long polling could work? The chat is going to be open pretty much every day from early afternoon to late at night, but not all users will be active all the time. Still, on average probably five or six users will be online without leaving for a whole day, every day. When we're the most active, there will be times when a lot of messages are sent in a short period of time, but it's hard to estimate how many.
Would it be worth looking into the use of Websockets using the PHP server implementation of those and with a Flash fallback (for desktop use we're fine since we all use Chrome, basically, but we'd be happy to be able to use Android devices as well).
I also stumbled upon www.pusher.com and their free alternative looks quite suitable, with 20 connections and 100 000 messages per day (we won't nearly reach that much even in a week). Would you recommend we simply go down that road instead?
I know there are loads of questions here regarding push technology with PHP and Apache, but I haven't found anything addressing a situation where there will be such limited use of the application. Any tips and suggestions would be greatly appreciated. I pretty much know how I'd write the chat itself, I just need to know the best method to use, and if any of the above will work.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've been thinking about creating a chat application, but don't know too much about how to create an effective one so I was hoping we could talk about the "best" and most efficient(performance) way to making one.
So the base features are probably seeing each other's messages and a chat log.
So I was considering using codeigniter and ajax to create the view and sending of each message and every time a message is sent, the message is sort in a table for the chat log. Then I thought, if every time a message is sent a query is sent, the scaling of this app would be horrible, so I was thinking of storing the log on the client's cookie or javascript object and upon leaving the chat, the log is sent and stored in the database. But then I don't know if this would work or would be extremely bad security wise.
Also, I was reading stuff on stackoverflow about chats and websockets and ran in ajax APE as an effective way to manage sending messages... But I don't really know much about websockets and how to use them etc...
Anyhow, I'm pretty sure I can make a chat application, but a good, effective, scalable one, no...
Any suggestions on the best/most effective way on making a chat application?
Some of u suggested node.js or socket.io.
Since I don't know anything about those two, which one is better?
Also I noticed that in the node.js example that he uses one server for the whole chatroom, does that mean I need a node.js server for every chat/chatroom?
Even though you are thinking about building this with PHP and AJAX, I highly, highly recommend doing something like this with Node.js if that's an option for you. It is much more suited for something like this; especially compared to AJAX which uses expensive HTTP requests in relation to Node.js A big benefit of it is that it is incredibly fast at doing many kinds of I/O and is asynchronous. Also, the Node.js process is non-blocking which helps make it even faster.
You should have a look at this example as well. The code was written by the creator of Node.js himself. Also, Node.js can interface with databases so you don't need to use text-based logs or anything.
If you're interested in WebSockets but don't want to deal with catching all of the cross browser quirks, definitely check out Socket.IO. It's a library for working with WebSockets and I've found it to be very good at dealing with all of the different browser versions out there.
Hope that helps!
node.js and socket.io seem the most appropriate for this task.
node.js allows to handle many persistent connections with low memory usage, which is quite suitable for handling all chat clients. socket.io is an abstraction over websockets / comet / long-polling that allows to pass messages between the node server and a web browser.
You can still use codeigniter or any other framework for the user interface.
If you were really going hard core big, you might want to think about replacing the database for message queues. Second Life put up their message queue evaluations for in-game messaging.
http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes
Although, chat logs would not likely be persisted on your server like they would with a database.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm wondering what's the right way to code a chat application for thousands of users.
I'm just confused how will I be able to ping the server using AJAX every second or maybe less and check if there are new records in MySQL, etc with an acceptable amount of server(s) load.
I'm currently thinking about coding this using jQuery, PHP and MySQL.
Please advice. Your help would be greatly appreciated.
Client Side
For any program that needs to poll the server I would recommend WebSockets.
I wrote an extremely basic WebSocket tutorial. I also used the web-socket-js code to implement a FlashSocket that will make it work across Firefox, IE 8+, and Chrome, as well as any browser that supports WebSockets.
I don't believe that polling would be a good choice for a chat application. While it would work, the request overhead would be much higher then using a WebSocket. The tradeoff (benefit) is that more browsers support it.
Also, hitting a MySQL database to see if there are messages is going to incur a good deal of DB overhead. I would recommend using a MySQL database for chat logs, and only keep a limited number of "back" messages on hand for new connections. Then simply broadcast new messages to all connected clients. The frontend application would then take the message and append it to chat window.
Server Side
Node.js is an evented server-side JavaScript framework. While it is still young, several very interesting applications have been coded in it. The Node.js people setup a chat program (not WebSockets) the source of which has been made available. That would be a very good place to start if not wanting to write it from scratch.
There is a PHP WebSocket implementation. Depending on your requirements it could be used just fine. Having coded in both Node.js and PHP I would say I think Node.js is a better fit for this.
On the server side, you'll need a script that can tell whether or not there is new content (eg: messages) based on a timestamp (eg: last request). On the client side, you have two options:
Polling aka Periodic Refresh:
This basically means having your client poll the server in intervals to check whether or not there is new data. What you want is to keep your requests and responses as light as possible. It could also help if run the script handling these requests in a separate process.
It will be up to you to tweak the interval to one that's acceptable for both the server and the user. You can also use a Heartbeat to tell whether or not the user is still active, so you can stop polling the server if the user left the window open but is off the computer.
HTTP Streaming aka "Comet":
Using this will require some more setup; but this is basically a long-lived connection from the client to the server and the server can "push" content to the client when necessary.
Heres a simple looking websockets example: http://www.dashdashverbose.com/2010/02/nodejs-websockets-stoopid-easy-comet.html
I assume your max amount of users would depend mostly upon your connection and server software.
You could also try out IcePush - it is an ajax framework for pushing messages FROM the server TO the javascript client. This would be a perfect match for a chatclient!
If you are a java developer, you can use jwebsocket to implement the server. there are various examples on their site to start with as I'm also going through some of them.
Briefly from their website
jWebSocket is provided to you to create innovative HTML5 based streaming and communication applications on the web. HTML5 WebSockets will replace the existing XHR approaches as well as Comet services by a new flexible and ultra high speed bidirectional TCP socket communication technology. jWebSocket is an open source Java and JavaScript implementation of the HTML5 WebSocket protocol with a huge set of extensions.