Hello webmasters,

I have a website about memes and I want to update the database each time the user scrolls down.
I have no problem when I make a few requests to the database, but what if I want to do a lot of requests in a large database?
I recently had to refactor my code to exclude some code that is important just for the sake of performance.
Is there any way around it? How does Facebook do it?

How Facebook does this is with their very own Cloud computing platform. We all wish you could have that problem but the question how Facebook does that is out there. Example: https://en.wikipedia.org/wiki/Open_Compute_Project is the open source design of their cloud compute hardware.

You can write to an in-memory table or to a cache (such as memcached or redis) with rolling activity logs, and then do batch jobs to update multiple rows in the database at once.

What is your front-end (or better yet, what is the URL of the site, so we can see the front-end)? A couple of things worthy of a search are "debounce" and, if you have jQuery, "scrollstop" since these will fire much less frequently than window.onscroll.