If you create an api it might be a lighter load. You need to manage your resources more carefully because runtime is shit on these web servers that you get for like $1.
|
Okay so i rent webhosting from trentahost as a vps.
Lately Vps connecting to remote sql has been slow as shit.
Voting for example lags a player like 5 seconds, and when starting my server it takes ages before gtl is connected.
Now the odd thing is that when i connect to the remote sql from my local computer it connects almost instantly and there is no lagg/delay.
The vps connecting to the sql is causing server laggs with highscore saving/when alot of players vote.
Anyone got any idea what the problem could be?
You shouldnt use mysql connection on server to connect to database. There are better ways of doing it for example http requests.
Yeah but in the long run googled learned me what is causing it i downloaded my raw access logs and the way someone is trying to bruteforce my vps is also sending massive amounts of requests to my webhosting, haven't found a way to block it yet since the ip/user agents keep changing >.> btw is the maintaince in progress? i was rebuilding my vps with a vpn till the dedicated ip change would come trough and now im offline
Buy a more expensive VPS when using allot of MySQL most of the cheap VPS servers can't handle that many queries.
Otherwise (whitout upgrading your vps) just generate a rand unique id on your VPS and confirm it on your PHP (web host) depending on what id u get u will get the right page, than just execte the querys on the web server instead of your VPS.
When one id is used generate another for someone else ex: voting or highscore update or anywhat.
No. Just no.
My personal recommendation would firstly, use a connection pool. The c3p0 library is excellent for this, and it's incredibly easy to use:
You can retrieve a connection from the data source, just make sure to close the connection and appropriate statements after use, to return them to the pool. The delay would likely be due to latency between your server, and SQL provider (speaking of which, why don't you just host the SQL server locally, rather than making remote calls to the database? MySQL is incredibly simple to install). If you're just using the database to update highscore rows, you can execute the queries on a separate thread. Similarly, you'd want to query and process the vote queries and reward processing on a separate thread.Code:private ComboPooledDataSource pool = new ComboPooledDataSource(); pool.setDriverClass("com.mysql.jdbc.Driver"); pool.setJdbcUrl(String.format("jdbc:mysql://%s:%d", host, port)); pool.setUser(username); pool.setPassword(password);
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |