09/12/2022

2022/12/09#p1

0 comments: click to read or leave your own

Back in May I started looking at making feed fetching in /reader more efficient and explored the options for running PHP processes in parallel. Unfortunately, the common methods (async, pthreads, parallel) are not supported by my hosting.

The library I'm using to consume feeds uses cURL (if installed, file_get_contents() if not) to grab the feed contents but doing this repeatedly for multiple feeds takes time — with the 29 feeds I had it was taking around 18 seconds to do a full refresh.

I recently came across 'cURL multi' 1 which allows the processing of multiple cURL handles asynchronously so wondered if I could make that work here. On Wednesday evening, as is my way, I started overcomplicating matters thinking I was going to have to rewrite the library. Tired and confused I went to bed wondering how I was going to achieve this.

Yesterday, however, I realised that, rather than need to rewrite things, I could just make a couple of the private functions public and call the library one stage further in. Instead of the library making single cURL requests, I could do the multi requests first and pass the results to the (now public) later functions.

The upshot is that a full refresh now takes less than three seconds for 31 feeds — a sixth of the time it was previously taking! As I add more feeds the time savings will only get larger.


  1. I'm still learning my way around PHP. I haven't got to classes yet, using them confuses my old brain. 

Leave a reply



Cancel comment

You can also:

Reply by email Reply by email Send a webmention Send a Webmention

2022/12/09#p2

0 comments: click to read or leave your own

There is no roadmap for the site and I often think to myself "what next?" Features and improvements get added when: something is not working; causing a pain point or obviously better if done another way; or, inspired by someone or something else.

At the same time as looking at running PHP threads in parallel I was thinking about ActivityPub support but that is so far beyond my ability. I know I always say that and then get something working but, in this case, I really mean it. There is also no actual reason for me to add it anyway.

I'm always looking to tweak and improve, never seemingly happy with the status quo, but trying to force something into the site when it's not needed is not the way to go.

Leave a reply



Cancel comment

You can also:

Reply by email Reply by email Send a webmention Send a Webmention

2022/12/09#p3

0 comments: click to read or leave your own

The past week or so has seen a marked uptick in spam login attempts on the site. I don't have to check logs because of the feature I built to send me an email. Those emails include the source IP address and a link to block it – one click, done! It's reassuring to then get further emails advising that login attempts have been blocked. It's good to know the system is working, even if it is a very simple system.

Leave a reply



Cancel comment

You can also:

Reply by email Reply by email Send a webmention Send a Webmention

Colin Walker Colin Walker colin@colinwalker.blog