How To Make Cloud Function Scale?

Recently our project launch and we have lot of users when first launch we forgot about upgrade our server and server was down pretty quickly because of many users we hand, and then we upgrade it and it kinda usable again, and then more new user coming and then it down again

after that i tho my code was bad because on homepage we had expensive aggregation
so i try add index on mongodb in make my web 50% faster but if i stresstest it i only manage about 100 user so i try to create somekind of cache system cache saved on mongodb

cloud function request > run expensive query > get response > save mongodb
and then if new user hit the same url with same parameter
cloud functon request > check if there is cache > send response

this system make my web load faster from 800 ms / request to 100 ms / request

but i keep stresstest it again it only manage to handle 200-400 user with response time up to 10000ms / request

then hmm i think mongodb made this lag so i try to save the response on variable
using this method i manage about 500 users with response time up to 5000ms
they way cache work it just
i create hash with md5 from request.params as the key and save the response

USING variable As Cache it handle 265 user pretty easly

when it hit 750 users my server crash

my hope is i can handle atleast 1000 users with some kind of lag 500-1000 ms