trueferret
Posts: 3
Joined: Sun Apr 01, 2018 10:11 pm

Website hosting on RPI 3B+?

Sun Apr 01, 2018 11:00 pm

I want to build a soccer tips website using nodejs and express and host it on a raspberry PI but I don't know what kind of performance can I expect from a 3B+.

I know I could just host it on a cheap platform, but I've wanted to get my hands on a PI for some time, and it will help me learn Linux (esp. the setup part that I can't risk on my notebook).

It would be a simple website, with a database like mysql to store the results from this api each hour and update modified predictions in my db, the front-end would use VUE and I will also need to send emails using this email API.

Would the 3b+ be able to handle up to 50 concurrent users?

User avatar
bob_binz
Posts: 441
Joined: Thu Feb 02, 2012 7:58 pm
Location: Stockport, UK

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 9:01 am

Just give it a try and see.

Worst case is it doesn't and you need to revert to a cheap host; but then you have the Pi to continue your learning journey!

--
BBz

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

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 9:28 am

I'm fairly certain a Pi 3 can handle what you want to do. node.js is very lean and quick. The solution may be 10 times slower, or whatever, than a PC but a PC can handle thousands of concurrent connections with node.js so 50 on a Pi is nothing.

Unless your database is really huge and the users are hitting it multiple times per-second. Or you are continuously streaming data with websockets.

If I were you I would just get on and build it. If I'm wrong and performance sucks then it's easy enough to move it all to another platform.

Or, what about scaling it up with more Pi? Have two or three serving those web pages.

Just now I'm experimenting with a cluster of three Pi 3 running the distributed, fault tolerant, CockroachDB.
viewtopic.php?t=200748

Cockroach has an interface very similar to Postgresql so it's very easy to use and much more robust than MySql.

With multiple Pi you have scalable performance and fault tolerance. Great stuff.
Memory in C++ is a leaky abstraction .

User avatar
B.Goode
Posts: 12308
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 9:35 am

Would the 3b+ be able to handle up to 50 concurrent users?


Although not directly RPi related:

If you are planning to host this website yourself, will your agreement with your ISP or other network provider permit you to run a service that handles 50 concurrent incoming connections to your network?

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

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 9:50 am

Good point. One that I tend to forget as I have never had an ISP complain about my home server activities.

I don't think the number of concurrent users is an issue. HTTP is a stateless protocol. The connection is made, a request received, a response sent, the connection closed. With only 50 users there will almost never be more than one connection open at a time. Unless one is using websockets, for example, which keep the connection open for a long time.

Outgoing bandwidth use might be an issue. Sounds unlikely to me.
Memory in C++ is a leaky abstraction .

MaxVMH
Posts: 114
Joined: Mon Mar 19, 2018 1:26 pm

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 9:59 am

I'm developing a soccer prediction web application and testing it with 20 (real-life) users that log in and set their predictions every week. Then I enter the results and the web app calculates the scores (link to GitHub if case someone is interested, the code is written in English but the web app user interface is in Dutch - I'll probably make a translation in the summer).

Haven't had a single problem with the performance, Raspberry Pi 3B running Raspbian (Lite ofc), Apache, MySQL (MariaDB) and PHP. I didn't do any performance optimizing (except for setting the GPU memory to the minimum of 16MB). Since you want to run a database server, I recommend getting a USB hard drive. Database servers don't play nice with SD cards / USB sticks.

So yes, I think it's doable. If it doesn't work out, you can always switch to paid hosting and use the Raspberry Pi for local development, use it for retro gaming or just sell it.

I also have a WordPress blog on another Pi 3B and another WordPress blog on a Raspberry Pi 3B+ . The Pi 3B+ also does the reverse proxying to the other servers.
The WordPress blogs are not as snappy as the self-written web app and the blogs get very few visitors so I don't know how that would be holding up with a decent amount of traffic.
Eventually my plan is to make the Pi 3B+ the Apache / PHP server and a Pi 3B the SQL server, I'm waiting to set that up when the soccer season finishes in a couple of weeks to not disturb the users that are testing the soccer prediction web app.
Webserver stack: 2x Pi 3B | 1x Pi 3B+ ||| Pi Zero W for fooling around

Working on a soccer prediction web app:
https://github.com/MaxVMH/mijnscore
Attempt at writing up-to-date tutorials on making a Raspberry Pi webserver:
http://blog.mijnscore.be/

trueferret
Posts: 3
Joined: Sun Apr 01, 2018 10:11 pm

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 4:18 pm

Heater wrote:
Mon Apr 02, 2018 9:28 am
I'm fairly certain a Pi 3 can handle what you want to do. node.js is very lean and quick. The solution may be 10 times slower, or whatever, than a PC but a PC can handle thousands of concurrent connections with node.js so 50 on a Pi is nothing.
Its not a problem that it isn't super fast, I don't think I'll get 50 users anyway.
Unless your database is really huge and the users are hitting it multiple times per-second. Or you are continuously streaming data with websockets.
The database would be really small, I don't think it would grow larger than 100mb in a year.
Just now I'm experimenting with a cluster of three Pi 3 running the distributed, fault tolerant, CockroachDB.
viewtopic.php?t=200748
This sounds a bit complicated for my technical skills at this moment, although distributed computing sounds like something I would want to look at in the future.

I think I'll just go ahead and build it, thats the overwhelming feeling that I get after seeing all the replies.

The only issue that I haven't figured out yet is related to the ISP.

trueferret
Posts: 3
Joined: Sun Apr 01, 2018 10:11 pm

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 4:30 pm

MaxVMH wrote:
Mon Apr 02, 2018 9:59 am
I'm developing a soccer prediction web application and testing it with 20 (real-life) users that log in and set their predictions every week. Then I enter the results and the web app calculates the scores (link to GitHub if case someone is interested, the code is written in English but the web app user interface is in Dutch - I'll probably make a translation in the summer).
Unfortunately I don't understand much PHP to comprehend what is going on there, it sounds interesting and since you are already doing similar things on a Raspberry PI I will start coding my project, hope I won't have any issue but as you said I could switch to paid hosting if it doesn't work out for me.
Haven't had a single problem with the performance, Raspberry Pi 3B running Raspbian (Lite ofc), Apache, MySQL (MariaDB) and PHP. I didn't do any performance optimizing (except for setting the GPU memory to the minimum of 16MB). Since you want to run a database server, I recommend getting a USB hard drive. Database servers don't play nice with SD cards / USB sticks.
I'm curios on why I would need a USB hard-drive? Isn't the usb port of the RPI still USB 2.0? Would I get better performance than a class 10 SD-card?
The WordPress blogs are not as snappy as the self-written web app and the blogs get very few visitors so I don't know how that would be holding up with a decent amount of traffic.
Eventually my plan is to make the Pi 3B+ the Apache / PHP server and a Pi 3B the SQL server, I'm waiting to set that up when the soccer season finishes in a couple of weeks to not disturb the users that are testing the soccer prediction web app. [/i]
Do you use something like Kubernetes or just LAN with both services running on two different RPI servers?

Thanks for your help

MaxVMH
Posts: 114
Joined: Mon Mar 19, 2018 1:26 pm

Re: Website hosting on RPI 3B+?

Mon Apr 02, 2018 5:29 pm

trueferret wrote:
Mon Apr 02, 2018 4:30 pm
I'm curios on why I would need a USB hard-drive? Isn't the usb port of the RPI still USB 2.0? Would I get better performance than a class 10 SD-card?
Database servers like the one you'll need do a lot of writes, it will make flash memory go corrupt faster than usual.
trueferret wrote:
Mon Apr 02, 2018 4:30 pm
Do you use something like Kubernetes or just LAN with both services running on two different RPI servers?
My Pi's are all connected to my router. The Pi 3B+ Apache server catches all incoming traffic. With virtual hosts in Apache I redirect the traffic to where it needs to be: either on the Pi 3B+ itself, or to one of the Pi 3B's.
Webserver stack: 2x Pi 3B | 1x Pi 3B+ ||| Pi Zero W for fooling around

Working on a soccer prediction web app:
https://github.com/MaxVMH/mijnscore
Attempt at writing up-to-date tutorials on making a Raspberry Pi webserver:
http://blog.mijnscore.be/

droleary
Posts: 174
Joined: Fri Feb 09, 2018 3:45 am
Location: Minneapolis, MN USA
Contact: Website Skype

Re: Website hosting on RPI 3B+?

Tue Apr 03, 2018 3:08 pm

trueferret wrote:
Mon Apr 02, 2018 4:18 pm
The database would be really small, I don't think it would grow larger than 100mb in a year.
If that's the case, you may be better off going with SQLite, and possibly using an in-memory database that you only dump to a file every so often.

markatlnk
Posts: 69
Joined: Sun Feb 23, 2014 7:53 pm

Re: Website hosting on RPI 3B+?

Tue Apr 03, 2018 3:11 pm

I have been running a live web site on a Pi 2 for the last couple of years. It does fine with a Wordpress Blog, web cam, and email system. With the fully qualified domain name, it gets log in attempts from all over the world every minute or so. With email, you will need to run spamassasin to cut down on the spam.

I do use an external 500G hard drive for the file system, only the boot partition is left on the SD card.

Works great, might migrate to a Pi 3+ one of these days, I need to move the system anyway.

I also don't allow comments on the WP blogs, it is mostly vacation travels for my own memory and for my dad.

If you want to see it, be nice, just go to zjunk.net



Mark

Return to “General discussion”