Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


What's better for huge static website?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

What's better for huge static website?

hanoihanoi Member
edited June 2017 in Help

Hello there,

I'm going to make a static article site. But I'm wonder 10k-30k articles on database (like Mysql, tuning by Redis or Memcache) is better than 10k-30k articles on 10k-30k static html files.

And what about if more than 300k articles?

Is anyone experience with big site like that can help me?

Thanks in advance.

What's better for huge static website?
  1. What's better for huge static website?60 votes
    1. Database (SQL or NonSQL)
      16.67%
    2. Static html file with SSD or RAM Disk
      83.33%

Comments

  • Static html files would make your site faster; however, if ever you need some fancy functions like commentaries or logins, database would be needed.

    Thanked by 1hanoi
  • SSD or spinning rust?

    I'd go with disk. less overhead... the OS disk cache effectively works the same as MyISAM tables, but without the application logic overhead. You'll also have slightly more memory for the disk cache without MySQL running.

    Thanked by 1hanoi
  • jgillichjgillich Member
    edited June 2017

    Static files will always be faster than any backend server with a database. However, you can use a HTTP cache like Varnish to achieve similar results. Just pick the right tool for the job.

    Thanked by 1hanoi
  • niknik Member, Host Rep

    You don't need a RAM Disk, you can just cache everything in RAM.

    Thanked by 2hanoi yomero
  • You are going to go nuts maintaining a huge static site like that if you don't have a server side application helping you out. Remember you can always automatically generate static pages from your dynamic pages for maximum performance. You can do fastcgi caching in nginx for example. You get the benefits of both dynamic and static pages when you do that.

    Thanked by 1hanoi
  • Serving static files should generally be faster - just make sure you have enough RAM for the OS to cache files appropriately and you should be good to go. The OS will take care of keeping recently referenced files around evicting stale files (etc.) but a caching proxy like Varnish will also help (more so because of application/content specific logic, while the OS is at the mercy of a lot of other "demands")

    Also, depending on the size of the files and how compressible they are, you should also consider storing them compressed and have them served directly without the overhead of (re)compressing them on the fly to clients (that support compression). It should also save a fair bit of IO at the expense (possibly) of a bit more CPU (which should still be better than IO waits).

    Plus with appropriate expiry headers you can go a long way in terms of intermediate caches and the likes.

    Thanked by 1hanoi
  • qtwrkqtwrk Member

    How about cloudflare's "cache everything"

    Since it is static , CF caches it , you are done , less bamdwidth , less request to server, no more trouble , no more worries

    Thanked by 1hanoi
  • hanoihanoi Member
    edited June 2017

    Thanks guys. That's exactly what I worry, huge IOPS if go with disk, and although with RAM cache, I don't know it will better performance/price than database or not.

    Maybe I will choice hybrid as your suggestion (I'm going to add to the poll but I can not edit it :D ). And with some dynamic contents like comments, like.. will go with self-hosted disqus.

    By the way, CloudFlare seem NOT cache everything unless you use Enterprise.
    Correct me if I am wrong <3.

  • RazzaRazza Member

    hanoi said: By the way, CloudFlare seem NOT cache everything unless you use Enterprise. Correct me if I am wrong <3.

    You can make Cloudflare cache everything via page rule even on the free plan.

    Thanked by 1hanoi
  • raindog308raindog308 Administrator, Veteran

    dedipromo said: Static html files would make your site faster; however, if ever you need some fancy functions like commentaries or logins, database would be needed.

    Not necessarily...lots of people using static + disqus and systems like that.

    Abdussamad said: You are going to go nuts maintaining a huge static site like that if you don't have a server side application helping you out.

    OP could use a static site generator like jekyll, pelikan, hugo, or one of a dozen others. Write a new page, run generate, and it rebuilds the site (usually only content that's changed).

    Thanked by 1hanoi
  • Static website using some control panel should create pages instantly. :)

    Thanked by 1hanoi
  • Came across this related/relevant discussion:

    https://news.ycombinator.com/item?id=14550060

    Thanked by 1hanoi
  • cnazhacnazha Member

    I'd recommend in-memory storage (Redis) instead of static HTML files, flexible and future-proof:

    • Easier to maintain: changing a template file is easier than changing 300k files...
    • RAM is faster than disk space: Redis could get around 1M requests per second
    • RAM disk is erased on reboot, you could resync with disk storage but why bother if Redis already has disk persistence

    Use NGINX as a proxy for express js with Redis as a database, you'll have the best of all worlds.

    Thanked by 1hanoi
  • DETioDETio Member

    You can use Netlify to host static sites for free if you want to cut costs, they are pretty cheap as well and can handle large amounts of traffic as they have a huge cluster of servers handling their service.

    Thanked by 1hanoi
  • cnazha said: I'd recommend in-memory storage (Redis) instead of static HTML files, flexible and future-proof:

    Possible, but scaling redis beyond a certain cluster size is not as simple as it sounds (neither is MySQL/MariaDB HA wise though), aside of that if you have memory.... why not? MemSQL is however also a very good candidate for such things.

    Else: static... what size do we talk here? Sure, lot's of HTML but what actual disk usage? 2 1TB SSDs for a RAID1 do not cost insanely much (or more smaller ones). HDD rarely makes sense if large random read and not much in-ram caching (eg. a lot of random requests or small RAM) but only for large files, and even that is simple solved then by rewrite/similar (or on proxy) to a HDD/SSD-cached/NAS array.

    Avoiding DB and having a plan to scale easily - static files certainly are if you have a way to push updates reliable and fast to all edges, but ultimately you just end up with proxies then anyway which you could do, like, in nginx, yo - sounds more reliable and easier to maintain in most cases.

    Thanked by 1hanoi
  • wwabbitwwabbit Member
    edited June 2017

    Will your entire website fit within the amount of RAM available for your server budget? If yes, then serve all the files from a ramdisk using nginx
    Otherwise, will your entire website fit within 2-2.5x the amount of RAM you will have? If yes, then look into lz4, lz4hc or zstd compressed ramdisk
    Otherwise, get the fastest SSD or HDD setup that you can afford (ideally 2x NVMe in RAID0). Run varnish or simply just nginx (filesystem caching is generally good enough)

    Next,
    1. Choose a static site generator from https://www.staticgen.com/
    2. Set it up either (ideally) offsite or on the server (make sure you have backups especially if you are using RAID0 on the server), together with all your source files.
    3. Run the generator
    4. Rsync the output to Ramdisk or storage
    5. If using Ramdisk, you will need a script to rsync from the staticgen output to the ramdisk during bootup

    Thanked by 1hanoi
  • varwwwvarwww Member
    edited June 2017
  • 100% static, don't use any database. It will faster, much faster than any dynamic website.
    Use nginx and offload images/css/js to different server, if you had budget use CDN.

    Thanked by 1hanoi
  • pbgbenpbgben Member, Host Rep

    Nosql in ramdisk

    Thanked by 1hanoi
  • pbgbenpbgben Member, Host Rep

    I would have a Backend like WordPress where I cN curate the site and make it the way I like. Then have a scraper making a static copy of the pages into a public nginx frontend that can be syncing between nodes via rsync and then roundrobin through dns like cloudflare, use BunnyCDN to reduce load on the nodes and boom.

    Thanked by 1hanoi
  • static is always better.If you have decent RAM, the OS will automatically keep the files in io RAM cache and use Nginx etc you can serve the files with very little overhead.

    Thanked by 1hanoi
  • I would also recommend having a dynamic site. And generate the static version , because your articles are not going to change.

    Because this way you have benefits of both. Only keeping static is not good for future may be?

    Thanked by 1hanoi
  • I would co with static website on ssd + cloudflare to minimize css + caching for faster loading.

    Thanked by 1hanoi
Sign In or Register to comment.