Lurker News
I’d like to learn more about backend development but most of what I find while searching are results like “Build a nodejs backend in 20 minutes” or “learn backend development in an hour.” I think part of the problem is I don’t know enough to ask the right questions.

Comments (130) 48 threads

natdempk4 replies#
There are a number of concepts that are worth learning about at a high-level if you want to learn about building large-scale projects. Most modern/large companies use some/all of the following to build their backends:

- Load balancers
- Web servers
- Caches (eg. Redis, memcached)
- Databases (relational, non-relational, document)
- Search datastores (eg. Elasticsearch, Solr)
- Log/event/message processors (eg. Kafka)
- Task queues/task processing libraries
- Periodic jobs (eg. cron)
If you dig into any of these there's a ton to learn, especially around looking into the underlying technologies used to build these higher-level systems.
There are also more conceptual things that are part of building/maintaining backend systems. These are a bit fuzzier, but I would say are also as important as the specific technologies used:
- Reliability
- Monitoring
- Observability
- Error/failure handling
- Migration strategies
- Data normalization/denormalization
- Horizontal vs. vertical scalability
This is by no means a complete list, but these terms are enough to get you in the right ballpark of ideas and start learning. I think highscalability.com is a great place to read about how other companies have built backend systems to solve specific problems. They have a massive list of quality articles written about various backend systems at scale.

chrisdsaldivar3 replies#
Yes: reliability, monitoring, and error handling were the types of things I’m looking for more information on. Do you have any recommendations for more information on these topics? I should have clarified that my question was geared towards important concepts agnostic of languages/frameworks/etc. This is a great list of further reading, thank you.

Also what does observability mean is this context?

jerf1 reply#
"Also what does observability mean is this context?"

Something went wrong, and now your site is serving 500 server errors to everybody at the rate of 25,000 per minute. The ops team already tried "just reboot it" and it didn't help. How are you going to figure out what is going on and fix it?
It's (mostly) too late to add anything, so all you've got is the logs you already had, the metrics you already had, etc. That's the "observable" stuff in a system. There's an art to recording what it is you need to know, while at the same time recording so much that you can't find what you need in the mess.
(The "mostly" is that if you have a good enough setup, you might be able to bring up a new system and route some very small fraction of traffic to it to examine it more intensely in real-time with a debugger or something, though in my experience, on those occasions I've had the opportunity to try this, it's never been a problem that would manifest on a new system receiving a vanishing fraction of a percent of the scale of a production box. But maybe you'll get lucky.)
You certainly want to do everything you can to not be in that mess in the first place, but it won't be enough. You need a system sufficiently observable that you can find the problem and find some sort of solution.

chrisdsaldivar2 replies#
Oh thank you, I didn't know that was referred to as "observability" I thought it was just logging. This article from Etsy's engineering blog [1] was part of the inspiration for this question. Funnily enough when I googled "Etsy engineering logging" the 5th result was for a position on Etsy's observability team.

[1] https://codeascraft.com/2011/02/15/measure-anything-measure-...

Continue this thread — 2 replies

natdempk#
jerf answered observability well in another reply to this comment.

As for reliability, monitoring, and error handling I've heard good things about the Google SRE book: https://landing.google.com/sre/books/
I haven't read it personally, but I've heard good things from others and looking over it briefly the advice there lines up with what I've experienced in practice.

aynsof#
You might want to look into honeycomb.io and follow Charity Majors on Twitter. Heck, just follow Charity anyway - she's a genius.
scarface7410 replies#
I agree with most of that list - except for cron.

Cron jobs are the definition of the anti pattern of treating servers like pets and not cattle. You have to worry about that one non redundant server running your cron jobs. There are others ways to skin the cat, but my favorite is Hashicorp’s Nomad. I like to call it “distributed cron”. Together with Consul for configuration it’s dead simple to schedule jobs across app servers - the jobs can be executables, Docker containers, shell scripts, anything.

natdempk#
I agree that is definitely the way to go at some scale. :) I really just put cron on there as an example of how someone might think about scheduled jobs as most of the more advanced things are conceptually similar to cron, but where you don't have to worry about where your job is actually running and how the environment was setup.

I think it is worth noting for any of the systems above that there's a spectrum of possibilities around how much you automate/offload the management of them, as well as plenty of backend systems for managing those.

freedomben#
These days I think of "cron" as more of a type than an actual implementation. When somebody says, "I need a cron job" my answer these days would never be, "ssh into www1 and add it to the crontab." It would be, "create a CronJob type in Kubernetes."

But I agree and concede, a user with zero back-end experience will just google "cron" which will take them to a crontab example, so they will likely be mislead into the anti-pattern, as you said.

whalesalad#
It's just as important to understand the history/genesis of cron as it is to know when to not use it.
gravypod2 replies#
> Cron jobs are the definition of the anti pattern of treating servers like pets and not cattle

What's old is new again. Much of clean distributed systems development is now built on, what is essentially, scheduled period operations. They're pretty much the least complicated ways to loosely couple domain logic in distributed systems that follow eventually-consistent semantics. They're also a good model for the functionality of many distributed scheduling systems like Kubernetes, AWS' ECS Scheduled Tasks, and more.
Kubernetes even goes so far to have Jobs (batch operations) and CronJobs (scheduler that creates Jobs).

scarface74#
I use AWS’s native services most of the time like CloudWatch to schedule jobs, lambdas, and step functions these days, but to keep the post generic, I mentioned Nomad/Consul that I have used in the past for an on prem implementation that kept us from having to bring Docker into the mix. Since we were already using Consul, using Nomad just made sense.
hestefisk#
Depends on the use case / workload.
igotsideas#
Still good to know for legacy fixes.
zwetan1 reply#
doesn't work when you can not access the machine where the cron is supposed to run for security reason or whatever

there crontab is not an anti-pattern at all

scarface74#
What does not having access to the server have anything to do with using a fault tolerant solution?
sl1ck7311 reply#
That is only true if your jobs aren't doing a stateless operation. I use cron all the time on cattle VMs. No reason to cargo cult extra stuff into the mix.
scarface745 replies#
Until that one server goes down in the middle of the night or it has issues.

Or if the server doesn’t go down and your cron job fails. Do you then implement retry logic in every job since cron can’t do retries automatically?

Continue this thread — 5 replies

sudhirj#
Learning the cron format is still necessary / useful - most distributed deployment systems have some form of schedule job running. Even on a purely serverless model like AWS Lambda, it’s still possible to do distributed crons. I actually think the word ‘cron’ has already been repurposed - when using it my team actually refers to the distributed version, not the per server version.
roadbeats#
Hey - why not just systemctl ? It’s quite robust and reliable.
coldtea1 reply#
>Cron jobs are the definition of the anti pattern of treating servers like pets and not cattle.

Cron jobs are the definition of "if it works don't fix it" and YAGNI.

scarface744 replies#
But cron jobs don’t work when you need server redundancy or retry logic.

Continue this thread — 4 replies

pcmaffey#
A good portion of this falls under the purview of "data engineering" which is another conceptual layer to think about / research.
malkia#
For some of these concepts - take a look at what Envoy + Istio , linkerd (and other service meshes) are trying to solve and conceptualize: load balancing, auth(n/z), monitoring, logging, etc.
eranation4 replies#
I'm a bit terrified that no one had security as their first item on the list. Many answers here are great and contain a lot of important concepts, frameworks and tools. But all of these are meaningless unless you have a strong spider sense for security. Not just the OWASP top 10, or top 100. But also criticizing your own business logic, not leaking information to the client side, not pushing things to git that should not be pushed. How to securely store passwords in the database. How to handle DDOS. How to prepare for the worst case, limit blast radius, all this while not hurting your productivity, as well as the end user's.

In the official sense, Security also includes availability (see the CIA triad), so a large portion of the bullets others have mentioned focuses on that.
I think a security mindset (including availability, which leads to thinking about disaster recovery, performance, redundancy, high availability, distributed systems as a mechanism to achieve it etc) is the first aspect that I look in a backend developer.
Other things are important, but security mindset in my opinion is the first layer in the foundation.
Others on my list that may be helpful to deep dive into:
1. HTTP, REST, know it well.
2. GraphQL as a complement/alternative to REST.
3. If using relational databases, learn what is a N+1 selects issue and how to solve it
4. If using NoSQL databases, learn about the CAP theorem and understand the tradeoffs etc
5. Learn to avoid premature optimization. Measure and profile before jumping to conclusion on theoretic bottlenecks that don't exist.
6. Unit test all the things, learn how to mock and what to mock, learn the difference between unit and integration tests.
7. Invest time in good design, read some other open source projets, see how they organize the code, what packages, what modules. Learn about dependency injection, Inversion of control.
8. Learn some cloud patterns, such as exponential backoff, throttling
9. Know everything about cookies, localStorage, XSS, CSRF, JWTs, and session cookies, stateless vs stateful architecture etc.
10. DevOps: Look into containers and serverless, CI/CD
11. Multithreading if you are in a language that has them.

rorykoehler1 reply#
Spot on. Security should be baked into the way you work. It should be baked into an formal CS education too. I have joined teams full of seniors and "leads" who on paper should be miles ahead of me in terms of experience and competence and have had to teach them the basics you mentioned. It immediately creates a stressful overhead of constant auditing, nagging and unnecessary stress in the team when security is introduced after the fact.
therealdrag0#
Yep. I've worked in on a multi-tenant product in which I've seen senior engineers write APIs that would have allowed one tenant (enterprise customer) to access the data of another tenant!! Insane.
chrisdsaldivar1 reply#
Security is absolutely important. You’re right that most programmers don’t consider it and even my CS degree programming never emphasized security. However, I did a cybersec emphasis so I always consider the security implications of a system at the design stage. It’s significantly easier to build a secure system than it is to retrofit an insecure one.

One of the most important concepts is the principle of least privilege which is rarely ever discussed. Every tutorial I’ve seen, even paid ones, (this isn’t to say all of them) give their app master DB credentials. You could vastly improve your applications security just by leveraging your DB engine’s native access control.
For those using Postgres here’s a great resource for setting up RBAC: https://www.postgresql.org/docs/9.0/user-manag.html

ralala1 reply#
How much of the typical application server authorization logic can we put into the database? Is it possible to setup authorization on a cell-level? Example: All users may change their own passwords, but only team admins may change the passwords of other users in their team.
chrisdsaldivar#
I have never attempted this particular use case but, as far as I can tell this isn’t possible. While it is possible to grant privileges to change another user’s password, you would have to either make the team admin a super user (this grant all possible privileges) or by granting the Create Role privilege (which would allow them to create a new role with privileges they aren’t intended to have and switch to that role) so neither of these options are really any good.

A clarification on my previous comment: The way I’ve used Postgres RBAC is to create roles for each service in my application that needs DB access. For example say you have a service (in my case typically a lambda function) that only ever reads data from the DB and only from specific tables. I would create a role that only grants SELECT privileges for those specific tables. This also disallows UPDATE, DELETE, ALTER etc. privileges. Then assign this service that role. This mitigates the possible damage done if that service is compromised and shrinks your applications attack surface.

bashwizard#
Most devs are terrible when it comes to security. At the same time I'm glad they are because without them I'd be unemployed today.
fipple#
My perspective, having sold a company: security isn’t that important until you’re big. When you’re small you’re a small target, your resources are better spent on features and sales, and if you get hacked you can change your name and pretend you’re a new entity. I know this isn’t the ethical answer but it is the realpolitik answer. Invested maybe 50 dev-hours in security over 4 years.
endymi0n#
No matter what you're going to read here (and there's all good stuff), number #1-3 on my list are simple requirements engineering:

- Understanding in depth what you are supposed to be building, as directly as possible from the stakeholders. Nothing is worse than building the wrong thing perfectly right.
- Coding that understanding into a data model (read: database schema) with great, clear naming, correct entity relationships and as many constraints as possible (including correct types) early on.
- Understanding the front end part that will serve your application and how it interfaces with the users. Only that will give you the details on how to build the API that will serve it.
Iterate these three points until you're done with the application skeleton and only then write the first line of code. If there's anything that will make you insanely productive as a backend developer, it's these crucial first steps of requirements engineering.

pjungwir3 replies#
It sounds like you're just getting started, so I would say: pay attention to the "seams" between layers/modules/components/machines/etc. Especially these days when we are building higher and higher abstractions, you will understand a lot better if you examine how things interface with each other. You will learn more deeply & more correctly, and it's a great way to debug problems. For instance:

Find out how to make your ORM log the SQL it's running, and try running that in your database directly. If you are having trouble, get the SQL working first, and then figure out how to make your ORM generate that SQL.
On the web, use View Source and/or Inspect Element to see what is really in the DOM.
Look at the Javascript you're serving. Is it what you think it should be? Maybe the problem is in your webpack config or caching or something.
If SCSS is giving you trouble, look at the CSS it's generating. Is it what you expect?
If there is a problem submitting a form, look at the Network tab to verify the right things are being sent. Understand how HTTP works here. Try putting the same request into `curl -v`. (Browsers even have a "Copy as cUrl" command nowadays.) If that looks okay, see if Rails is turning your submitting into the right params (or whatever your framework is).
One nice thing about checking the seams is you can debug via binary search: first see if the problem is in the browser or the server. Next see if it's in your app or the database. Next see if it's in your controller or your model. Etc.

bennylope1 reply#
> If you are having trouble, get the SQL working first, and then figure out how to make your ORM generate that SQL.

This, specifically, is very good advice: using the ORM as a tool to implement a SQL-first solution. And not just good advice for beginners.

C1sc0cat#
Why use an ORM.
desc#
This. Visibility into what is actually going on, and the drive to understand it. Troubleshooting, debugging, learning: all the same thing, but tarred with different parts of the process. Dig into what's actually going on and understand the layer under you.

tl;dr: Keep digging, because everything's worth knowing at some point.
It's generally much easier to fix a bug in your own code or infrastructure if you're familiar with the innards of the things you depend upon directly, and learning your preferred platform beneath the current frameworks is a solid advantage because it helps you move sideways when the next New Framework comes along.
But there's also the conceptual side, the general concepts which have remained unchanged for decades, which a detailed knowledge of a specific platform (eg. Java, .NET, Node.js) doesn't necessarily aid with. These probably won't even feel relevant on a daily basis, but will definitely multiply your effectiveness over the long term.
Some things which might fall into that category:
* SQL and relational databases (especially if you're not using SQL, because you'll be reinventing it for any nontrivial amount of data)
* Consistency models and distributed systems (capabilities and limitations; some things can never be waved away by technology)
* The operating system, and principles of its design (not necessarily in any great detail, but knowing roughly how software talks to hardware is very useful, especially when assessing the marketing blurb for any cloud platform)
* Complexity theory (stringing three 'optimal' algorithms together might be textbook, but often you can apply some domain knowledge to cut out a step or two to reduce actual runtime and maintenance overhead)
I've found stuff like graph theory, principles of compiler design, and a working knowledge of assembly code to be useful too, but that's probably the far end of the bell curve for web server stuff :P
Computer Science is a subset of mathematics and it's amazing which bits of pure maths turn out to be useful in my day job. Shame I'm not very good at that stuff... but reading enough about it to recognise when it's applicable can mean the difference between 'picking a good library off the shelf' and 'hacking together a terrible solution myself'.

flukus#
Inspecting the DOM, client side javascript and generated CSS are all front end concerns, not stuff for back end development, even if many of us do both.

> Find out how to make your ORM log the SQL it's running, and try running that in your database directly. If you are having trouble, get the SQL working first, and then figure out how to make your ORM generate that SQL.
Time would be much better spent learning SQL properly. ORM's have their place, they can cut down a tonne of boilerplate, but anyone using an ORM should be somewhat competent in SQL already. If you learn SQL from ORM output then in many cases you'll be learning what not to do.

Load more comments