I'm using my raspberry pi model B as a web server. I chose node.js since its something i'm most comfortable with. I used nginx too because I have multiple node.js apps and wanted different domains / sub domains on the same IP.
The problem I am experiencing is poor page load / data receiving speed.
For example, my test site on the raspberry pi is loading very slowly : http://missile.io . The effects of the slow speed is even more drastic when I do a database query and return the results as json : http://missile.io/songs. I replicated the same codebase and database in an amazon EC2 micro instance and the speed is about 10x faster.
Is this because of my ISP ?
I'm using a 100Mbps connection with direct Ethernet cable on my Raspberry Pi. I don't actually experience a 100Mb/s speed, in fact when i do a simple wget to test download of a large file, i'm downloading at 250kb/s.
How can I fix my problem?
2 Answers 2
There likely is no problem, this is probably what you're paying for.
I have a colocated pi serving webpages. As this is hosted in a data center with proper network I don't have this issue. If you're hosting something via your ISP and not a hosting/colo copmany you're not being realistic in your comparisons.
Just because the NIC on the pi is 100Mbps does not mean you're going to get that upload speed via a home ISP. Visit Speedtest from a desktop on the same internal network as your pi and run the test, this will give you an idea what to expect. 250Kb/s isn't uncommon for uploading on lower level residential broadand contracts.
Most ISPs also throttle network connections, do traffic shaping and many don't allow hosting servers/websites from home.
If you're concerned that your application has problems, benchmark/profile it.
The question seems to be asking two different things and possibly only being answered in one part.
If you have poorer download speeds, by a wide margin, when you download something from the internet to your raspberry than to your regular computer then there is something wrong with your raspberry or the network from the router to your raspberry.
if you are experiencing poor page delivery times when you are trying to access webpages from your raspberry to your local computer on your local network then you might have an issue with your setup on the raspberry.
type top in the terminal and check how much memory you have left. Check if there are any processes that go high on the CPU and stay there for a second or more. which one if so? Check how much memory mysql consumes. or whichever db you are using.
I had problem with long page loads and a hunt to remove every single trace of php in the application started. Once I got rid of that and sticked to pure node js code then I must say I am very satisfied with the speeds.
I am running v2 of pi with 512mb ram and I have provided only 16 to the graphics. I have never attached a screen so that makes it nice and lean.
I am running the processor at standard speed.
the internet
(from another machine, like EC2 server) at 256kilobytes per second. That is more than enough for any experimental server to serve up simple web content on an idle internet connection. Even if they have 100mbit upload which not even you knows- Clearly they have at least 32mbit which is sufficient.