Taco So how would flarum hold up on peak hours? I mean, if it creates a new connection to the database every fetch.
You're delving into the land of caching ?
Think about what happens during a connection to a website using a LEMP stack (Linux, Nginx, Mysql, Php) in regards to possible caching
You touch the webserver (nginx) first, then PHP, who then calls mysql if needed, all while on linux.
All of these make requests that slow down the process since they must do work to return a valid response.
The solution to make things fast, is to have your computer do less work.
Linux
Linux is amazing at caching, something you probably won't notice on a server, but if you have the luxury of using a linux desktop with plenty of ram, you may notice funny little things occurring like repeated searches that suddenly become super fast, videos loading without spinning up your external hard-drive
This has more info about linux caching -> http://www.linuxatemyram.com/
Nginx
Nginx permits caching of results. I have a user who I manage a server of where they have a blog. Intermittently, their quiet site will get thousands hourly, typically of just one page. My nginx simply returns the html result of the previous identical request, which requires almost no work.
-> https://www.nginx.com/blog/nginx-caching-guide/
PHP
But if its a new page, or a expired old cache page, it will check again. Here php runs the php script. During this process, it is converted to bytecode and that bytecode is run against the interpretor. But if the file doesn't change, why not keep the bytecode? But yes, it does need to make a request to the database, which leads us too..
-> http://php.net/manual/en/intro.opcache.php
Mysql
When you make a query to mysql, you are asking for information about something. What happens if that request is frequently identical? (eg, what extensions are enabled currently), why not return a already generated result?
Pitfalls
Security:
The moment you start configuring caching, you must consider what could happen if things go wrong.
If you cache dynamic pages (You and I see a similar page, but you're logged in as Taco
, but I'm logged in as Kulga
), you can suddenly serve pages to the wrong party and have significant security issues (like being able to act as somebody else since the server thinks you're both the same person)
Updating:
If you update a server (eg flarum), and your php has the old version cached, what happens when you try to use the new one? I've had many crashes that were because php cached the old code
Misoptimization:
More is not always better. Throwing too much ram for one caching service takes it away from others, while too little could cause it to malfunction. For example, optimizing mysql can be very frustrating.
Take away is if you want to use caching to optimize your speed by helping your computer do less, be aware of what could go wrong. Apologies for deviance from topic - I like caching ?
As for why I like flarum, its extensibility is my favorite part, even though I don't know how to create extensions myself ?