Skip to content

Hifumin Bismarck

Latest
Compare
Choose a tag to compare
@SaltyAom SaltyAom released this 31 Jul 05:46
dc92cb7

Named after the German battleship "Bismarck" which is named after "Otto von Bismarck".

Bundesarchiv_Bild_193-04-1-26,_Schlachtschiff_Bismarck

Published at hifumin.app

Bismarck is a complete rewrite of Hifumin in SvelteKit instead of Nextjs with a lot of cutting-edge features, cloud saves, and solid structure for future development planned ahead.

But most importantly, notable features and changes are:

  • Rebranding from Opener to Hifumin
  • Seele, a fast custom search engine combined with Akashic Server
  • Migrating from Google Cloud to deploys.app, improving roundtrip by a lot, expected request in SEA is <100 ms
  • API Mirror server, which updates every 9 hours, no data is needed to scrap from nhentai API on production
  • API caching, with API mirror done, every update of the mirror will trigger the API server to redeploy with mirror server bundled as cache, no need for external request if data is in the cache, results in a very fast response time.
  • Galahad, a user data API server, save data across devices in the cloud.

Seele

Since Atago, Akashic, reverse proxy nHentai as GraphQL was created under Hifumin and published as a public API.

Everything is good with Akashic, it works like a charm.

Receiveing GraphQL requests then mirror requests to nHentai, a perfect reverse proxy API server.

But I feel like it can get better.

So I change the strategy from just-in-time to ahead-of-time requests.

Instead of getting data at the time of request which will have delayed around 0.5 seconds, Hifumin Mirror, a CRON service that get data from nHentai every 9 hours and publishes it to the Mirror server to reduce the load from nHentai.

Then after the publication of the mirror server, Hifumin Mirror then triggers the deployment of Akashic, bundled it with mirror server data into the container then public.

This results in absolute 0 external requests to nHentai API if requested hentai published more than 9 hours, as the data is read from the file system instead of waiting for API response.

The server is blazingly fast, less than 0.01ms to response (this included parsing GraphQL AST, reading from the cache, and calculating transform the response structure)

As the experimental feature of the custom Hentai Search Engine is finished, it's merged into Akashic and renamed Seele.

Migration from Google Cloud to deploys.app

Google Cloud is great, it has almost everything I could think of to create Hifumin.

However, it's too complicated for Hifumin.

You see, Hifumin is just a serverless container running alongside together, it needs no complex infrastructure at all.

Deploying Hifumin to Cloud Run is great, but after an enormous DDOS attack of 100M requests in less than 5 minutes, the billing spike.

Requiring me properly set up cloud-native infrastructures for HIfumin, and turned out it required a lot to receive that huge load.

These are services required to handle the setup Hifumin in GCP:

  • Cloud Run
  • Cloud Build
  • Premium Static IP
  • GCP SSL/TLS issuer
  • Layer 7 Load Balancer
  • Serverless Network Endpoint Group (Serverless NEGs)
  • Cloud CDN
  • Cloud Armor
  • VPC Group
  • Cloud NAT
  • Cloud Router
  • Serverless VPC Connector

There's too much service running for a free Hentai server, the billing is too expensive for me as my country pays a lot lesser than other countries, and as I gain an absolute 0 penny from Hifumin, I couldn't afford that.

FYxvKyPUEAEi_71

So I found with AcoShift in Svelte Meetup, and he talks about his service, deploys.app which only needs me to just published the serverless container and his service will handle the rest from:

  • Anti DDOS
  • Fast roundtrip time
  • Autoscaling
  • Cheap price
  • Price by CPU time

Behind the scene is an advanced K8S cluster running across a big cloud and backed by Cloudflare.

I also noticed that request made in SEA is now very fast, request is resolved in <100ms which feels almost instant.

After a month of using deploys.app, Hifumin costs is reduced by 28x compared to Google Cloud.

So, all Hifumin service is now running on deploys.app

Galahad

Bismarck introduces Galahad, a user data-center API.

Bismarck will now store data like favorite hentai in the cloud instead of on the device, to enable seamless and continuous reading from across many devices.

The database server is using PlanetScale, a cloud-native database that scales up to millions of queries/seconds and more.

And require seamlessly using Prisma, and ending in Fastify, one of the fastest server of Node.js

Hifumi

Hifumi is a frontend service of Hifumin (this current repo)

As mentioned, Hifumi is completely rewritten in Svelte instead of Nextjs which we gain:

  • Much cleaner codebase and architect
  • Even faster performance in both code execution and load time

We also handle caching, and rate-limit inside the container via Varnish, and NGINX.

Styling is entirely rewritten from scratch with the help of WindiCSS, resulting in no unused style or component at all.

And with a custom GraphQL library written, Hifumin can be fully utilized efficiently way to handle GraphQL requests and caching.

All these combinations working together, make the Hifumi feels almost instant.

Outline

It has been around 9-10 months since last released, Hifumin has grown so much since the idea for Stupid Hackathon Thailand.

I couldn't have thought that I would end up creating one of the most advanced hentai platforms out there.

But besides it is a hentai platform, I've learned so much and grown with it.

I feel happy to be working on this project, and I couldn't be here without all of your support of Hifumin.