Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
CitizenKeen
Nov 13, 2003

easygoing pedant
Hey, just checking in. Long-time lurker, first time poster.

So... I'm in over my head. One of my toy apps blew up. I started last July. On February 1 I had about a thousand users, most unpaid. As of this morning I have about 19k users (of which 10k are active on a weekly basis). March was the first month where I tried to make money and I'm looking at about $1k in my first 30 days.

I wrote the app using Razor Pages as an HTMX experiment; had I known what I was doing I probably would have used Vue with a more traditional API model. Not writing any Javascript was a fun idea when it was just for fun.

(I'm a later-in-life career-change dev. I work in Enterprise software where it's stale and safe.)

I don't have any specific problem other than that I don't really know how to grow on my own (don't really want to talk side-hustle at work). I've spent the last week learning about nginx so that I could figure out some buffering issues.

Just wanted to introduce myself because I'm increasingly running into problems that I can't solve by myself (or I can but only after weeks of searching).

Adbot
ADBOT LOVES YOU

CitizenKeen
Nov 13, 2003

easygoing pedant
Responses:

Sorry, still looping this thread into my "check up on". My bad.

Yeah, the page is mostly just data retrieval, with one huge form. That form might be better as an SPA, but I don't think it's worth turning the whole page into an SPA. I get a lot of positive feedback on how thin the site is, so I think I made the right call.

I am running into a problem though, and I have no idea where to begin solving it. This is mostly devops, stuff, though - if there's a better thread, I apologize. I think I'm running into some scaling problems. I've gone from 1,000 users in February to 24,000 now, so it's been a bit wild.

I'm seeing these spikes in my processor and my users are reporting intermittent 502s...

https://imgur.com/a/gd3Z3W6

I have no idea how to debug that or where to begin.

I'm running a .Net 7 Razor pages app on a Digital Ocean server with Postgres. That's about it, pretty bog standard. I've made a few small changes to the nginx config based on googling to increase some cache buffer sizes, but otherwise it's mostly out of the box. No cron jobs, no scheduled recurring processes. Just Entity Framework queries and a few views for intensive reads.

(I'm also running a Discord bot using DSharpPlus, but that's mostly a wrapper around two commands which pull some basic static info from my site.)

I don't know if Postgres was the right choice - it was free and its syntax matches SQL Server which I'm used to at work - because my understanding is that it's optimized for writes instead of reads and my site is pretty read heavy.

I'm kind of lost on how to start tracking down why my server's CPU just starts running away. (It's an 8 gig / 4 Intel basic CPU box on Digital Ocean). I can afford to double those resources if I'm just running into resource limits, but I'm concerned it'll be like urban traffic and just swell to fill whatever new stuff I provision.

Any thoughts on where to start investigating this? Please and thank you.

CitizenKeen
Nov 13, 2003

easygoing pedant

redleader posted:

can you set up your hosting thing to capture a process dump if cpu spikes above 90% or something like that? we've done that with our azure thing in the past, but no idea what sort of tooling digital ocean offers in that regard

can you correlate request count or duration with the spikes?

could there be users with an unusually large number of somethings? example: at a previous job we had strange intermittent perf problems that ultimately arose from a bot who had added thousands of items to its cart (normal number of items would have been less than 20 or something like that)

So the site is hosted on a DigitalOcean VM, so I have pretty hefty ability to add what I want to it, but it's just a hosted Linux box so I don't have true god mode.

The problem is, I don't know what kind of tooling or tracing or anything I should be pursuing. I started this project to learn some industry practices that my management team doesn't value enough, but this scaled faster than I expected.

All I've got in place is Serilog.

I have a search syntax DSL where users can write very simple queries against the data; I'm wondering if I left some infinite regression in there or something. I'm going to have Serilog write out all queries to a separate log file so I can look over what kind of queries people are writing.

Right now, the things I need to learn are:
  1. How do I evaluate my code in production?
  2. When do I know that my code is good enough and the bottleneck is needing to buy more hardware, versus needing to figure out bad loops in code.

I also need to set up a staging environment; that would probably alleviate some of my stress.

CitizenKeen
Nov 13, 2003

easygoing pedant

nielsm posted:

You evaluate your code in production by instrumenting it with logging that captures data that can help answer your questions, without interrupting the normal request handling. What data your need to capture depends on the application.

Is that something I can do with Serilog, or is that a separate kind of logging?

CitizenKeen
Nov 13, 2003

easygoing pedant

Rawrbomb posted:

If you think the issue is with the user written queries to the database, you could enable some query logging for queries that are taking over a set amount of time. I'm pretty sure PGSQL has some settings to enable and capture this. Might be another option to help you figure out what's going wrong.

Oh yeah, that's probably a good idea; I'll investigate what PGSQL has. Then I'll have to parse backwards from the SQL that Postgres is running to the EntityFramework it's generating - that might be a mess, but it's my mess.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply