DEV Community

Discussion on: Building Gophercises

Collapse
 
joncalhoun profile image
Jon Calhoun

For your error - stackoverflow.com/questions/323253... has a few suggestions that all looked like they are actually helpful. Don't just read the accepted answer either, see some of the other suggestions and see if they can help out (the one code snippet looks potentially promising)

Having said that, are you actually running into this error in the real world? Are you coming anywhere close to 1k req/sec?

I know we all like to have code that scales indefinitely and stress testing can be fun, but if it were me I'd likely not worry about this issue too much until it actually become an issue. For example, Gophercises has 10k users, but never gets anywhere close to 1k req/sec. That would only happen if like 10% of my users all logged into the website at the exact same time which is really unlikely. Instead what typically happens is that I'll announce a new course and over a 5 minute period 10% of my users might visit the site, but my server is handling each request pretty quickly so I end up never exceeding something like 10 req/sec even with a lot of real users. As a result worrying about this issue isn't a high priority right now.

If you are trying to learn and are just curious then by all means keep digging and see what you find (and update me on what you find! I'm more curious now 😀) but if you are just worried about your app crashing I somewhat doubt this is actually going to be a problem until you have quite a few users.

Oh and about the source - it isn't currently open sourced. I hope to open source more of my code at some point, but I'm not sure when.

Collapse
 
avjinder profile image
Avjinder

I did do a lot of digging, and one solution I found was changing the "no. of open files limit" on linux using the ulimit command. By default the limit is something like 1024 files, but this can be changed using ulimit.

I'm not actually seeing this error in real life, these api's are for small private businesses and their employees, so about 50-100 connections per service, with about 200-500 req/sec. I know premature optimization is the root of all evil, but I wanted to make it scalable and future-proof :]