vps vs home server ?

tufanv

Expert
Licensed User
Longtime User
Hello,

Due to increased number of my applications which requests data from my vps every 2 seconds like finance apps , I am having trouble with my vps. I am currently using 2 CPU cores ( intel xeon ) and 2 gb ram. No problem with ram , but on peak hours my both cores are nearly full.

I have to upgrade to a next vps plan which will require about 70$ / month and will provide me 4 cores and 4 gb ram , but i am also not sure if it will be enough in the future . I have some other plans which will also require cpu.

This makes me ask the question, what about having own server with a high end computer ?

after some research the problems may be :

*Electricity ( which wil require a power supply in case of electrycity problems )
* symetric internet connection of around 10mbps / 10 mbps . I am not sure if 10mbps upload speed will be enough for these ?
* Advanced routers with firewall

I would like to hear your ideas about it ? what would you suggest.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
No problem with ram , but on peak hours my both cores are nearly full.
Is this a B4J server? How many clients are requesting information in peak hours? Might be better to use WebSockets instead of polling the server.

There are several issues involved with hosting your own server:
1. The upload bandwidth, which is the important metric for servers, is usually limited.
2. Reliability. Do you suffer from electrical outages or network issues from time to time?

I think that a home server should only be considered if it is not possible to use a remote server (the UI cloud is such an example) or for small solutions.
 

tufanv

Expert
Licensed User
Longtime User
Is this a B4J server? How many clients are requesting information in peak hours? Might be better to use WebSockets instead of polling the server.

There are several issues involved with hosting your own server:
1. The upload bandwidth, which is the important metric for servers, is usually limited.
2. Reliability. Do you suffer from electrical outages or network issues from time to time?

I think that a home server should only be considered if it is not possible to use a remote server (the UI cloud is such an example) or for small solutions.

No it is not a b4j server.

1) yes it is the main problem. For about 90$ / month , we have a symetric internet available with 10mbps upload. But currently my server shows an average of 1.3 mb/second transmit traffic. ( which is high for a 10mbps upload I think )
2) No electrical or network outage happens in my location.

main problem for me is the cpu cores for my current vps. for two cores my vps uses at an average of %60 cpu, and when peak times , the server is crashing sometimes. I am not sure if i upgrade to next plan with 4 cores will solve the problem. Dedicated servers are too expensive. I can build an extreme computer but the problem is the network i think in this case.
 

billzhan

Active Member
Licensed User
Longtime User
You should use VPS or dedicated server for most of the time. The network connection reliability and availability are very important. The latency between server and clients should be reduced.

Also you need a backup plan when the main server is down, it could be the server hosted at your home or other datacenter. Regular backups for important data in main server(s) should be taken and transferred to backup server.

Linode is a famous VPS provider (recommended, not sure if credit card is needed).

Other ones I've used: Vultr Digitalocean. They are charged hourly with many OS templates.
Amazon lightsail is a new VPS, I've not tried yet.

Dedicated server will provide stable CPU power and memory, less noisy neighbors. More time and skills are needed however.
Some low price provider: online.net, ovh.com (kimsufi.com)

Moreover, avoid to use Windows server if you don't have enough experience and time to maintain the securities issues.





 

tufanv

Expert
Licensed User
Longtime User
What is the server doing? How is it implemented?
I am using a linux vps. I think I misdescribed the situation. There is no other server. I host a domain on this vps and this domain has many php files which my apps use it to get info from the mysql database. Also this server use a b4j generated jar file to send http requests everysecond to a remote server to get finance data and write the results to my mysql server.
When I use htop to check the server resources , I see many apache interfaces and at peak times the cpu usage is nearly full.
 

sorex

Expert
Licensed User
Longtime User
tufanv,

you can call yourself lucky that they didn't ban your IP yet for doing so much frequent requests. that's almost DDOSing you're doing.
 

tufanv

Expert
Licensed User
Longtime User
I would start with switching to a WebSocket server instead of polling the server every 2 seconds. It will be much more efficient.
Are you talking about Http reqests For getting data from the remote server and store those values in my database ?
 

tufanv

Expert
Licensed User
Longtime User
tufanv,

you can call yourself lucky that they didn't ban your IP yet for doing so much frequent requests. that's almost DDOSing you're doing.
this is why i pay much for a professional finance data. I dont think there is a problem with sending http request every second, what option do i have to get data that changes every second and which they told me to send http reuests to get the latest data.
 

sorex

Expert
Licensed User
Longtime User
if that is what they prefer then you're fine I guess. hopefully their firewall keeps the gate open then :)
 

tufanv

Expert
Licensed User
Longtime User
if that is what they prefer then you're fine I guess. hopefully their firewall keeps the gate open then :)
yes but every http request consumes cpu and when there are 200 300 people requesting at the same time , makes problem for me =)
 

sorex

Expert
Licensed User
Longtime User
can't you fake things to lower resources?

fetch the data on your sever every 30 seconds and store the current value and the difference step with the previous value / 30.

in the app you add the step to your current fetched value from your server so that it looks like it changes and correct it after 30 seconds.

your sever and connection load will be 29 times less per connected device.

I doubt their servers are updated every second aswell.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Are you talking about Http reqests For getting data from the remote server and store those values in my database ?
No. If I understand correctly the mobile app sends a request to the server every 2 seconds. With WebSockets the server can notify the connected clients when needed. So polling is not required.

BTW, have you enabled opcache on your Apache server? If not then you should. It will make the server run 10 times faster.
 

tufanv

Expert
Licensed User
Longtime User
No. If I understand correctly the mobile app sends a request to the server every 2 seconds. With WebSockets the server can notify the connected clients when needed. So polling is not required.

BTW, have you enabled opcache on your Apache server? If not then you should. It will make the server run 10 times faster.
I don't think it is enabled by default. When I update a php code, the cache has to be cleared everytime I think , is that correcT ?

I asked my vps support,they said you dont need to clear the cache if you dont have cloudflare cdn on the domain. is that correct =?
 
Last edited:

tufanv

Expert
Licensed User
Longtime User
Another question for you people ,

When I monitor bandwith usage of my server with iftop , on average around 2 mbit /second is being used , sometimes it makes a peak to around 5-6 mbit / second for just 1-2 seconds and comes back to 2, 2.5 mbit /second (talking about transmit).
If I build a setup in my office for server, The internet connection I can use is 10mbit symetric. Will it work like the current vps ? Logically , it should because it doesn't go over 10mbit even at peak seconds but practically the situation may be different as with the vps I am on gbit shared network while on the home server i will be on the 10 mbit .

Thanks
 

udg

Expert
Licensed User
Longtime User
In part it depends on how strictly your provider stays close to the 10Mbit maximum bandwith claim.
In Switzerland, if they sell you a 20Mbit you got the whole 20Mbits and added services like phone or TV don't eat up slices of that.
In Italy, they generally serve you 10% to 50% of the bandwidth you signed for.

I'm sure that for your office you will sign for a professional service, but sincerely I doubt you will end up with as much bandwith as agreed on and a level of service comparable to that assured to a big data center.
Data centers are served by new redundant fibre lines, while your private office could be served by fibre to the road cabinet than copper or, even worse, by old lines plagued by terrible signal/noise ratio. Maybe this is a prior check you can do (quality of lines, distance from cabinet and from provider exchange).

udg
 
Top