vendforce
Posts: 1
Joined: Mon Jan 04, 2016 6:12 pm

Webserver

Mon Jan 04, 2016 6:14 pm

A question can you use raspberry pi2 in a cluster for a web server I know its possible but is it practical
You can get cheap hosting for 10 dollars a month but I'd like to have physical access to my server and I want to build a quiet low energy cost web server option that I can leave running 24/7 without being really noise etc
I suppose my real question is building a 2 cluster raspberry pi2 , would it be able to allow lets say 20,000 people to view the website and browse at any one time or would I need like 10 of them or more for it to be workable. I'm aware I need a load balancer and a fast Internet connection or is this just madness and I'd better off buy a hosting package online

ejolson
Posts: 5968
Joined: Tue Mar 18, 2014 11:47 am

Re: Webserver

Tue Jan 05, 2016 12:31 am

vendforce wrote:A question can you use raspberry pi2 in a cluster for a web server I know its possible but is it practical
You can get cheap hosting for 10 dollars a month but I'd like to have physical access to my server and I want to build a quiet low energy cost web server option that I can leave running 24/7 without being really noise etc
I suppose my real question is building a 2 cluster raspberry pi2 , would it be able to allow lets say 20,000 people to view the website and browse at any one time or would I need like 10 of them or more for it to be workable. I'm aware I need a load balancer and a fast Internet connection or is this just madness and I'd better off buy a hosting package online
These days the average webpage size is about 1.8MB; however, let's assume that only 0.12MB per page is actually served by your server and the rest is pulled in from advertising sites. Since the maximum network speed of a Raspberry Pi is 100 mbps or about 12MB/sec, then assuming 50% efficiency, about 50 pages per second can be served by a Pi. In particular, a Pi could serve 20,000 people a new 0.12MB web page every 7 minutes. Realistically, anyone serving webpages using a Pi will probably have no more than 50 people accessing their server at a time. In this case, a new page could be loaded by each person every second.

The main difficulty in setting up your own hardware is the expense of a suitable network connection. Typical "high-speed" residential connections have asymmetric speeds, which are advertised according to their downstream speeds but often only 2 mbps upstream. Since 2 mbps is 50 times slower than the Pi, using faster hardware is moot. Note, however, as high-speed upstream speeds can spur economic growth, there are a few governments currently experimenting with making such infrastructure cheaply available. Therefore, it is possible that a 100 mbps upstream connection would not cost that much where you are living.

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: Webserver

Tue Jan 05, 2016 12:48 am

You could set up the server instance on a single RPi and the use the free tier of the CloudFlare service. I've used them in front of a GitHub Pages static setup and they are pretty reliable for a CDN.
Account Inactive

User avatar
bugsy_malone 666
Posts: 292
Joined: Mon Dec 17, 2012 10:50 pm
Location: Basingstoke UK

Re: Webserver

Tue Jan 05, 2016 8:24 am

ejolson wrote:]These days the average webpage size is about 1.8MB;
I think in 2002 when I was doing web design they were about 1.8mb, then people started doing their own web design putting silly amounts of pictures in in super highres and the decimal point moved to more like 18mb or maybe 180mb, some days I am not so sure its even that low and thats before the adverts!

20,000 people at any one time seems alot of people to be viewing a website at any one time?

I guess one of the main points is whats going to be on the website? If you designed it in an old fashioned way, used low colour count gif pictures and coded the site to be like it was back in 2002 then you could get the web page down to say a few hundred kilobytes. it entirely depends on what your website does or if its just has text information. At that sort of size you'd probably be fine.

There are a few bottlenecks really for internet traffic: Connection speed, router, computer acting as a server and its network connection. So like I the pi's network bottleneck from what I understand is the fact the network runs off the usb channel.

To be fair, I think its a great idea to use RPis as mini data servers, you could have a PC as the load balancer (because you need network in and out) then a series of Pi's, but there are lots of ways of doing it.

Maybe one day this sort of thinking might actually make server PC's a thing of the past!

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Webserver

Tue Jan 05, 2016 9:44 am

I keep having to post this, so my apologies for the redundancy to regular readers, but the point is not getting across - you are _never_ going to see anywhere near the _theoretical_ maximum _instantaneous_ 100 Mbps on a 100Base-T Ethernet port, nor 480 Mbps on any USB 2.0 port, on a Pi or anything else using these technologies. Over the long term, you'll be lucky to get about 10% goodput - don't confuse raw-bit "throughput" with "goodput" - the latter is the intact bits that are actually delivered successfully. These are shared, asynchronous resources that rightly _assume_ there are going to be packet collisions, lost bits, and other Muphy's Law events caused by induced noise, imperfect cable/connector impedance-matching, cable loops/kinks, alien and government (one-and-the-same? :lol: ) interference, etc. Plus, there's generally lots going on in the ARM CPU that can further shrivel I/O performance - just run top at the command line, especially with a GUI running, if you don't believe me.

As for simultaneous web page serving, 20,000 isn't within the realm of reality for the simple reason that there is a severe limit in the number of connections that can be maintained simultaneously (it's more like dozens to maybe hundreds even if a Pi were running nothing but web server code, never mind a TCP/IP stack, an OS, etc.). Then there are the completely inaccurate raw bandwidth numbers being bandied about, but at least ejolson pointed out the typical asymmetric nature of most ISP "service", especially to residential customers. I'm currently visiting friends in a top one-percenter community and they're stuck with 750 _K_bps (yes, that's a K, not an M) DSL _downstream_ - the upstream throughput (not even goodput) is often less than 100 Kbps. I swear that smoke signals are involved in the connection somewhere, and the real irony is that one of the ISP's largest regional fiber and mobile data switching and hosting centers, that serves about 20% of its U.S. customers, is less than a few miles down the road! Ah, the curse of The Last Mile! :cry:
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

Pithagoros
Posts: 578
Joined: Wed Nov 12, 2014 8:16 pm

Re: Webserver

Tue Jan 05, 2016 10:59 am

Real world performance of a web server often does depend on the nature of the browsing it supports.
If your simple web pages are of the type where end users spend a lot of time per page, are stateless and use external linking then you will be able to support many more concurrent users than one with ajax type content, state, frequent postbacks and refreshes..

I've often been surprised at how well lightweight equipment stands up to the task of serving a website for work that is not TicketMaster or BBC news with a big breaking story.

User avatar
bstrobl
Posts: 97
Joined: Wed Jun 04, 2014 8:31 pm
Location: Germany

Re: Webserver

Tue Jan 05, 2016 11:07 am

The Pi 2 is roughly equal in performance to a Pentium 4:

http://www.phoronix.com/scan.php?page=a ... _old&num=1

Is serving 20,000 users possible? All of it depends on how you build your website and how it gets used. 20,000 requests per second is probably not going to happen even with static content:

100 Mbps / 20 000 Requests = 5000 bits of data, or 625 bytes per request not accounting for any overheads.

Make sure you use the latest Raspbian as Apache 2.4 and PHP 5.6 have significant performance boosts vs. old versions. Maybe even use NGINX/lighthttpd/monkey.

I have a Pi 2 colocated in the Netherlands with 100 Mbps upload, which the Pi can fill to about 90 Mbps. For small Projects its absolutely adorable :lol: .

If I am being honest though, you are better off getting an Intel NUC with a 1 Gbps NIC and a decent processor as those will trash most Pi clusters. A Pi cluster will hamper your network performance due to internal communications as well.

ejolson
Posts: 5968
Joined: Tue Mar 18, 2014 11:47 am

Re: Webserver

Tue Jan 05, 2016 6:26 pm

bstrobl wrote:The Pi 2 is roughly equal in performance to a Pentium 4
Except that many Pentium 4 motherboards have Gigabit Ethernet directly connected through CSA to the Northbridge, which is much faster than USB on the Pi. Therefore, even ignoring the advantages of SATA hard disks, Pentium 4's are much more capable webservers. Note, however, that consumption of electricity is an entirely different matter.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Tue Jan 05, 2016 7:32 pm

Jim,

You are right, we see so many unrealistic expectations of the Pi here. From raw CPU performance to network bandwidth.

However I'm guessing the Pi might be able to hold 20000 open TCP/IP connections. It might need some careful configuration. There are limits on these things imposed by the kernel that can be tweaked. Sorry I forget what they are called. Certainly a lot more than dozens or hundreds is possible.

Hmm...This is an experiment I have to try...

Are your friends in the "top one-percenter community" living up the tallest tree in Borneo?

Round here the worst, slowest, cheapest domestic internet connections I have seen for five years or more are 10Mb/s down and 20 or more up (Yes, outgoing faster than incoming) Free with the rent or maybe 10 Euro a month. Even deep in the forest we can get better than your figures using a 3G connection.
Memory in C++ is a leaky abstraction .

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Webserver

Tue Jan 05, 2016 7:37 pm

bstrobl wrote:100 Mbps / 20 000 Requests = 5000 bits of data, or 625 bytes per request not accounting for any overheads.
I have a Pi 2 colocated in the Netherlands with 100 Mbps upload, which the Pi can fill to about 90 Mbps. For small Projects its absolutely adorable :lol: .
The point made by Pithagoros about page content type drastically affecting response rate is well-taken, especially if there's additional processing going on, e.g., a database that your webserver is hitting to retrieve content that can be anything from a few characters of static text to GB-sized HD video blobs (that's actually a database type - Binary Large OBject).

The only way you're getting 90 Mbps is with at least a 100 Mbps switch port dedicated to the Pi, which is not a typical business service, let alone the residential service the OP very likely has if s/he's asking this question. You're lucky to get 10% of the theoretical maximum instantaneous bit rate on a typical subnet segment shared among multiple devices, i.e., there's significant contention for network resources, not just overhead that's unavoidable (e.g., network data/segments/packets/frames). BTW, encryption can easily chew up an order of magnitude of bitrate, especially if it's being done in software, which is usually much worse.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

ejolson
Posts: 5968
Joined: Tue Mar 18, 2014 11:47 am

Re: Webserver

Tue Jan 05, 2016 9:22 pm

Jim Manley wrote:BTW, encryption can easily chew up an order of magnitude of bitrate, especially if it's being done in software, which is usually much worse.
I get about 94 mbps between a Pi 2B and a Linux PC using iperf. This is pretty close to the theoretical 100 mbps hardware maximum. A Pi should be able to utilize at least half that bandwidth when serving large static pages cached in RAM. However, many websites are moving to https with SSL to prevent the injection of advertising and worse into their content using man-in-the-middle techniques. Note, for example, how the Raspberry Pi forums themselves are served through an encrypted channel, even though no sensitive financial information is being transmitted. Therefore, to fully answer the original question, it may be necessary to know how fast SSL runs using an encrypted webserver benchmark on the Pi.

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Webserver

Tue Jan 05, 2016 9:44 pm

Heater wrote:Jim, You are right, we see so many unrealistic expectations of the Pi here. From raw CPU performance to network bandwidth.
However I'm guessing the Pi might be able to hold 20000 open TCP/IP connections. It might need some careful configuration. There are limits on these things imposed by the kernel that can be tweaked. Sorry I forget what they are called. Certainly a lot more than dozens or hundreds is possible.
Are your friends in the "top one-percenter community" living up the tallest tree in Borneo? Round here the worst, slowest, cheapest domestic internet connections I have seen for five years or more are 10Mb/s down and 20 or more up (Yes, outgoing faster than incoming) Free with the rent or maybe 10 Euro a month. Even deep in the forest we can get better than your figures using a 3G connection.
Hey Heater - I think we're talking apples and rocks. The number of _simultaneous_ HTTP/HTTPS connections that a _web_server_ can typically accommodate is much smaller than the number of TCP/IP connections that the underlying system can manage, which is more a function of RAM, CPU horsepower (word size, clock speed, instruction set architecture, number of cores, etc.), system bus capacities, network interface goodput, competing processes, etc. The OP seems to be asking about lots of fairly small, static pages that each only requires a very short connection and then it's on to serving the next browser request, and if that's the case, then the early answers attempt to determine the number of pages per unit time that can be supported. Again, the number of simultaneous connections is a function of how complex the pages being served are, and whether the connections are stateless (which used to be the norm) or stateful, highly-interactive pages with lots of high-bandwidth content sources.

Europe is much more densely populated than most of the U.S. People outside the U.S. (and even those inside who live in metro areas) tend to not comprehend just how spread out we are, with Guam on the West side of the International Dateline ("Where America's Day Begins" is their territorial motto), Alaska being a good chunk of Europe in size, Hawaii is farther from the Best Coast than San Francisco is from New York City, and the continent is over 3,000 miles wide in longitude and around 2,000 miles tall in latitude. Only half of the U.S. population lives in/near metro areas, and the other half are in far-flung places that the LEast and Best Coasties call the "Flyover States" because they never set foot in them, which is a big shame and is helping feed the divisive politics of today. Those Flyover States and even the rural areas on the coasts are always the last to get telecomm upgrades because the cost is so much higher due to the very large distances needed to reach each business, let alone residence, everywhere. We have hundreds of thousands of Last Miles to connect and in order to do it at high speed, that means fiber, but even with all that's been laid, that's mostly been long-distance trunks and the low-hanging fruit in the metro areas, where wiring one building with thousands of users is very cheap per user.

However, wiring a single remote residence on a ranch in Wyoming can cost hundreds of thousands of dollars, and there's not nearly enough satellite bandwidth to service all of those kinds of customers at reasonable bit rates and cost, other than in receive-only broadcast mode, and my friends only have the option for satellite TV. They are retired and so high-speed Internet access isn't a big thing for them as they've never had it and wouldn't know what to do with it even if they did, plus their kids are grown and in/through college out-of-state. The typical comparison of South Korea as having the fastest Internet access per capita is a red herring because something like 95% of the population lives in one of four huge metro areas, one of which is one of the top three most populated metro areas in the world, depending on what day you count and what's been built, and the entire country is only a bit larger than New York State.

The same is true for whichever Scandinavian country boasts how much better their high-speed coverage is than the U.S., etc. Ironically, when I first got to Silicon Valley, it was one of the last areas to get digital PCS, 3G, 4G, and then 4G LTE cell service, and fiber-based broadband Internet because it was early into analog infrastructure investments, and it all had to be first augmented and then replaced at great cost in an urban and dense suburban environment. South Korea and Scandinavia never had such investments made that early on and have tiny areas to cover to reach nearly everyone not tending reindeer for a living (and I suspect even the reindeer have better 4G LTE coverage than I do right now! :lol: ).
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

hello world :-)
Posts: 121
Joined: Sat Nov 14, 2015 7:12 am
Location: England, in an insecure cloud, ie. The Interwebs
Contact: Website Yahoo Messenger AOL

Re: Webserver

Wed Jan 06, 2016 2:03 pm

Heater wrote:Jim,

You are right, we see so many unrealistic expectations of the Pi here. From raw CPU performance to network bandwidth.

However I'm guessing the Pi might be able to hold 20000 open TCP/IP connections. It might need some careful configuration. There are limits on these things imposed by the kernel that can be tweaked. Sorry I forget what they are called. Certainly a lot more than dozens or hundreds is possible.

Hmm...This is an experiment I have to try...

Are your friends in the "top one-percenter community" living up the tallest tree in Borneo?

Round here the worst, slowest, cheapest domestic internet connections I have seen for five years or more are 10Mb/s down and 20 or more up (Yes, outgoing faster than incoming) Free with the rent or maybe 10 Euro a month. Even deep in the forest we can get better than your figures using a 3G connection.
Last edited by hello world :-) on Sun May 15, 2016 3:15 pm, edited 1 time in total.
I do moral support. Here: https://www.raspberrypi.org/forums/search.php?search_id=egosearch
I know I use too many parentheses. Problem?
Topics I have posted in: http://bit.ly/1NbDdr5
My topics: http://bit.ly/1ObnKqQ
All my posts: http://bit.ly/1OHzje7

fruitoftheloom
Posts: 24452
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Webserver

Wed Jan 06, 2016 2:13 pm

hello world :-) wrote: Wow. Some people are so lucky. I have 3.4 Megabits/second average down and 1.3 Mb/s avg up, and I have Fibre/DSL internet. I'm in the UK, and not in any extreme kind of place either. Like I said, some people are so lucky.
TalkTalk FTTC aka SuperDuper

Upstream line rate (kbit/s):
2000
Downstream line rate (kbit/s):
39994
Thinking outside the box is better than burying your head in the sand...

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Wed Jan 06, 2016 2:33 pm

Jim,

Yes, we're talking apples and rocks.

Traditionally the web was stateless: connect, request, response, disconnect. For static web pages and even PHP backed, DB using pages, this was all pretty quick and transient. One simply did not have huge numbers of connections open at the same time. Talking of how many simultaneous connections one could support was ambiguous. You mean actual open sockets or you mean the number of people surfing your site now?

Of course if you are supporting users, you need to authenticate them and keep track of who is logged in. So you could speak of the number of simultaneously logged in clients you can support. But that is not really related to those current connections, connections are still transient and stateless.

But in the modern web we support "push" technology so as to get live update to the browser without it having to poll all the time. Think long polling where a request is made for some data and the connections stays open until such time the server has data to deliver, the connection is then closed. Or think websockets where a connection is opened and stays open permanently, the server can deliver data at any time it likes.

In the modern web "real-time" web the number of simultaneous connections you can maintain becomes a bigger issue.

So, yeah, my apples are those connections and my rocks are the actual rate at which one can deliver data.

You quite rightly point out that "The number of _simultaneous_ HTTP/HTTPS connections that a _web_server_ can typically accommodate is much smaller than the number of TCP/IP connections that the underlying system can manage". Except that it should not be "much". The overhead for those HTTP connections is whatever memory the HTTP protocol requires above a raw TCP/IP socket. The limit is the available memory space.

Anyway, sounds like I have to try a little experiment to see how many simultaneous HTTP/HTTPS connections a Pi can handle. Got to back up my hand waving somehow right?

Actually delivering data over all those connections is another matter....those are the hard rocks.
Memory in C++ is a leaky abstraction .

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Wed Jan 06, 2016 2:37 pm

hello world :-)
Wow. Some people are so lucky...
Don't feel so envious. Round here it's nearly -20C and the daylight hours are very short. We have to have high internet speeds because we don't go out for half a year at a time!
Memory in C++ is a leaky abstraction .

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Wed Jan 06, 2016 2:53 pm

Jim,
Europe is much more densely populated than most of the U.S.
Yes, but it's more densely populated than places around here that have excellent network infrastructure:

Rank Country

179 United States
182 Estonia
195 Sweden
203 Finland
213 Norway
Memory in C++ is a leaky abstraction .

Pithagoros
Posts: 578
Joined: Wed Nov 12, 2014 8:16 pm

Re: Webserver

Wed Jan 06, 2016 2:59 pm

hello world :-) wrote: Wow. Some people are so lucky. I have 3.4 Megabits/second average down and 1.3 Mb/s avg up, and I have Fibre/DSL internet. I'm in the UK, and not in any extreme kind of place either. Like I said, some people are so lucky.
We are in a VirginMedia area in the UK, so our is (I think) 150Mb/s amd it is due to be upgraded to 200Mb/s. But it doesn't make much difference really, because it just shifts the bottleneck upstream. It's no use being able to download at 200Mb/s if the host serving out the download has only got 50Mb/s available and it's sharing that across 10 connections.

It's good for multi-users though, kids on Netflix, Now and iPlayer.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Wed Jan 06, 2016 3:25 pm

150MB/s sounds great.

Have you tried something like http://www.speedtest.net to check that out?
Memory in C++ is a leaky abstraction .

Pithagoros
Posts: 578
Joined: Wed Nov 12, 2014 8:16 pm

Re: Webserver

Wed Jan 06, 2016 3:32 pm

Heater wrote:150MB/s sounds great.

Have you tried something like http://www.speedtest.net to check that out?
Yes, if I do it with a wired connection it says 150.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Wed Jan 06, 2016 3:42 pm

Awesome!

How much are you paying for that?
Memory in C++ is a leaky abstraction .

Pithagoros
Posts: 578
Joined: Wed Nov 12, 2014 8:16 pm

Re: Webserver

Wed Jan 06, 2016 3:53 pm

Heater wrote:Awesome!

How much are you paying for that?
It's the VirginMedia big Kahuna bundle. We are due to be upgraded to 200Mb/s in April.
It's hard to say how much it costs because it includes all the satellite TV Sky/BT Sport and everything, plus landline with unlimited free calls etc. It's supposed to be £55 per month but anybody with savvy on VM talks to their retentions team every year and we are currently on a deal for £43. Their new customers first 12 month offer is £34.99 pm for the same package.

User avatar
rpdom
Posts: 17699
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Webserver

Wed Jan 06, 2016 4:11 pm

Heater wrote:150MB/s sounds great.
I'm on their cheapest option, only 50Mb/s down.
Have you tried something like http://www.speedtest.net to check that out?
Yep, I've done that too.

Heater
Posts: 16826
Joined: Tue Jul 17, 2012 3:02 pm

Re: Webserver

Wed Jan 06, 2016 4:18 pm

Not bad.

We don't bother with any TV channels around here. I have never owned a TV in my life, let's just say that's many decades:)

'er indoors has not owned a TV for over five years. Seems there is enough TV streamed over the net now a days.

Me, I'm a YouTube junky now...
Memory in C++ is a leaky abstraction .

ejolson
Posts: 5968
Joined: Tue Mar 18, 2014 11:47 am

Re: Webserver

Wed Jan 06, 2016 6:55 pm

rpdom wrote:
Heater wrote:150MB/s sounds great.
I'm on their cheapest option, only 50Mb/s down.
Have you tried something like http://www.speedtest.net to check that out?
Yep, I've done that too.
Is this upstream or downstream or both? Some services only advertise the downstream, which can be 10 to 50 times faster than upstream.

Return to “General discussion”