Skip to content

Instantly share code, notes, and snippets.

@quetzaluz
Last active August 26, 2020 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quetzaluz/d4aff69ca81b43d4eb9780d89e7794fc to your computer and use it in GitHub Desktop.
Save quetzaluz/d4aff69ca81b43d4eb9780d89e7794fc to your computer and use it in GitHub Desktop.
Notes on status codes for my students

Core status codes -- can look at as a checklist when building API

REDIRECTS -- not common in restful design, more for navigation and page serving contexts but will come up

  • 3XX - any redirect case
    • 302 - TEMPORARY redirect, good to start with because permanent redirects (301) cache and cause bugs

More notes on DEVOPS!

502 vs 503, liveness probe

client
 \/			IF the client cannot even reach the proxy and
 			cannot even get a response from it, 502

proxy - load balancer - apache/nginx/f5/ELB common implementations
 \/			Usually happens after a long timeout.
 			IF something blows up between proxy and server,
 			AKA proxy ok but server bad, OR proxy can respond
 			in a basic way, but is broken in how it tries to
 			reach the server, THEN throw a 503
server


Another concept here -- "server timeouts vs client timeouts"
	- never have a timeout more than 30 seconds

more notes on a liveness probe

 SUCCESS_CODE = 204 // OR SUCCESS_CODE = 200 is also very common // Main reason for 204 in this example -- WE NEVER USE response.data, we don't NEED data! ​ setInterval(() => { fetch("https://something.com/liveness") .then( if (response.ok && response.status === SUCCESS_CODE) { . . . if successful, literally do nothing. Interval will rerun and re-check . . .) } else { throw Error('Bad status code or response'); }}) .error((e) => callAndEmailAndWakeUpAllEngineers(e)) }, 1000);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment