r/aws•
letsgodaledo

ORM/Validation Best Practice for Connecting Lambda to AWS RDS

technical question

Basically the title:

I am connecting Lambda functions to RDS Aurora (PostgreSQL). This is the backend for a mid-sized web app and a backend with ~20 tables.

I am debating wether to use an ORM.

Benefits:

  1. Decoupling data layer from code
  2. Assistance with database migrations as the app scales
  3. Assistance with validation/serialization

Concerns

  1. I am worried about the extra overhead of including an ORM in Lambda functions.

I've bounced between SQL Alchemy -> Marshmallow -> None (just psychopg2)

Complicating my decision, is that I am using the PostGIS extension of PostgreSQL to do some geo queries.

What do you think Reddit, is the overhead of an ORM worth it in a serverless app?

Posted Dec 21, 2019, 10:47 PM UTC

14
Scarface74•

I have a lot of mixed feelings about an ORM but it seems like you want to use many of the advanced features of it. I would say go for the ORM as long as you know the gotchas of using it and you know what it’s doing under the hood.

2
letsgodaledoOP•

What are your mixed feelings? As of right now, I'm leaning towards not using one. I am happily collecting all relevant opinions.

2
Scarface74•

I’ve just seen too many cases where developers used ORMs and created bad, non performing queries. It’s easy to shoot yourself in the foot for instance using EF and do a foreach loop over an IQueryable that causes database access on each loop iterations.

But if it’s a personal project and just you, go for it. Whatever makes your life easier.

2
franzwong•

Even without ORM, you can decouple data layer from code by adding DAO.

2