2
4 Comments

Looking for advice on web app optimization!

I'm planning to launch something similar to tiktokcounter.com, what kind of optimizations should I consider on my web app? This web app makes frequent calls to the API which would eat a lot of bandwidth and would need more computing power which I can't afford. I can of course reduce the refresh rate, whatelse?

on January 9, 2021
  1. 2

    Are you saying that if you don't do anything, you know for certain that your app will eat up more computing power than you can afford?

    If that's the case, you don't have a viable product at the moment. You need to revisit your technical solution - the code, the provider, and anyone else you pay.

    If that's not the case, then you're wasting time worrying about a problem you don't have yet. Don't try to optimize code, when you don't know what problem to solve.

  2. 1

    This looks like a perfect usage case for using AWS' API Gateway/Lambda/DynamoDB. It's super cheap (or free) to build as long as you stay under their free limits and there no servers you have to manage. Make sure you use the HTTP version of the API Gateway and not the REST one. HTTP is newer and 1/3 the cost.

  3. 1

    First id compare a few hosted offers no servers vs actual servers as this is going to be a peak load issue if you host it. Firebase is offering some counter service, I'm guessing it's going to be in the ballpark of 10$ per a million updates or something is that high/low?.
    Lambda type stuff as 2nd option
    Some stats counter service something like analytics services that are just basic counters.

    If you are hosting, you care about the payload mostly, you can use try to use like HEAD requests as they only have headers and no content...
    Btw incoming traffic is frequently free in many setups

    You might try to hack the logic into ngnix itself to push a counter into memcache that would be the least resources setup I think vs trying to code something independent
    Due not sure if memcache/redis counters would be blocking, if so you'd need a data store with eventual consistently that has fast non blocking writes like Cassandra iirc

    Statsd is an analytics counter with some efficient protocol..

    1. 1

      You can also fake update the counter with some growth formula based on history for the clients

      CDN caching+public caching is helpful for many viewers