Search code examples
c#phpserver-side

Server Side Applications - best practice?


I am not sure what the best practice is about coding server-side sometimes.

Lets say we have a rank tracker application which updates the domain google ranking for specific keywords. We create an application (e.g. Laravel Framework) which includes frontend and backend. Then we have to update the rankings for all websites from time to time. I know that a cronjob would help me to execute a script every few minutes.

But if it gets more complicated like the Uber Driving system... cronjobs will not be enough right? We need some server-side application written in C#, Java, ... which are continuously checking for tasks. right?

I just need some advice. Maybe someone could also point out in which case cronjobs are not enough and we have to use own applications (C#, Java,..) to make sure everything is working fine.


Solution

  • First you need to take a look at what Cron Jobs are used for: https://en.wikipedia.org/wiki/Cron

    The software utility Cron is a time-based job scheduler

    So in cases where you want to execute/task things at specific times, then a Cron Job would satisfy that need.

    If however you want to continuously check for a condition, and relay that information to-and-fro client and server, Sockets are generally what you're looking at. Specifically web sockets (in web based applications, also again depends on where/how you want to use it).

    https://en.wikipedia.org/wiki/WebSocket https://en.wikipedia.org/wiki/Computer_network_programming

    "Continuously" disregards the current time (I.e.: It's not the same as running every second, or even millisecond).

    Language also doesn't matter, but preferably you'd want to use something that has decent socket support / well documented libraries available.

    TLDR;

    Cron Jobs are good for when you want to do things at very specific times, like database backups. Where as sockets are more widely used to relay live information.