picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.83k stars 617 forks source link

First byte time and large amount of files in /blog #431

Closed omniperspective closed 6 years ago

omniperspective commented 6 years ago

Currently implementing picocms 2.0-beta-3 and I notice a strange correlation with the first byte time and the amount of files in the /blog directory.

There are some other directories with lage amount of files. I locally load fonts, preload dns and essential .css and .js files.

Some numbers:

/blog with 2000 files ; first byte time: 1,89 Sec /blog with 0 files ; first byte time: 423 milliSec

OK

schermafbeelding 2018-04-18 om 12 56 52

NOT-OK, long "idle time" and first time byte

schermafbeelding 2018-04-17 om 23 48 10

What I don't understand, what the pico code is doing IN this /blog directory that it is slowing down? What can I do resolve this behavior. If you want to look under hood, https://blenheim.biz

Any pointer is helpful.

PS. Not caching any of the data.

PhrozenByte commented 6 years ago

Pico isn't doing anything special with your blog directory, it is just discovering all your pages - and this takes some time for 2,000 pages. We'll squeeze the maximum performance from discovering files with Pico 3.0, but if you're depending on metadata (e.g. when sorting blog posts by date), you can't really improve this without caching.

In the meantime you can hook into Pico's onSinglePageLoading event to prevent Pico from loading specific files by setting $skipFile to true, likely depending on the currently requested page (i.e. prevent Pico from discovering files in the blog directory if it doesn't have to). This should improve performance significantly. However, managing 2,000 pages will always be noticable without caching. You should really think about adding some caching technique, or at least about how you could limit the number of pages.

dkyme commented 6 years ago

Have you had a look at the Plugin TooManyPages, @omniperspective ? https://github.com/bigicoin/PicoTooManyPages

omniperspective commented 6 years ago

@PhrozenByte Beste Daniel, thanks for your information, clear info. I will try to implement this fix, and see what gain I will get.

@dkyme Beste Dkyme, thanks for the information on the plugin, the name of the plugin was a no-brainer to understand that I was not the first person to encounter this behavior. I'm running on version 2.0-Beta-003, and I'm not sure if this plugin will work on version. But I will implement this plugin in a 1.0.6 version where I have the same issue's.

Thanks both. Regards Henk.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: