3

I am building a web/mobile application with Django Rest Framework (DRF) that enables authenticated users to post snippets and/or vote for other user's snippets. All users (authenticated or not) can also get the list of recent snippets (paginated, ex: 5 per page). Snippets, users and votes are stored backend in database.

I'm totally new to serverless architecture so I'm asking the question: is this application a good fit for this kind of architecture? Obviously, my DRF application is built around Web REST APIs which seems to be at first glance a good fit but the authentication part of users and paginated list of snippets let me think it could not be the case.

Can someone enlighten me?

Patrick
  • 141
  • 4
  • 1
    Check out JWT (JSON Web Token): https://medium.com/python-pandemonium/json-web-token-based-authentication-in-django-b6dcfa42a332 and the Serverless implementation: https://yos.io/2017/09/03/serverless-authentication-with-jwt/ – Juha Untinen Jan 02 '18 at 10:59

2 Answers2

3

'Serverless' is supposed to save you money by running your app via AWS Lambda or similar PASS hosting arrangements.

You pay per api call rather than having a server running 24/7

If your app is called only occasionally then you will save money. But if you app is in constant use you are probably better off with a normal server.

Its a bit more complicated than that, as you will need other things like IP addresses and databases. Really you need to try it both ways and see which is cheaper.

Ewan
  • 70,664
  • 5
  • 76
  • 161
  • Thanks for your answer @Ewan, more useful than these non constructive downvotes! But how do you address the authentication and the pagination processes with serverless architectures? – Patrick Jan 01 '18 at 19:26
  • Patrick - you are storing state in a database that is shared with different calls. User authentication/authorization could also be handled in you application, or you could use a service such as provided by google. Note there are projects like keycloak that make it easy for you to connect to multiple such services. You might consider prototyping with OpenWhisk. – Robert Baron Nov 01 '21 at 05:26
1

As opposed to serverless, you might be thinking of a microserver architecture.

In either case, you break up the API into smaller pieces. For example have a micro server handle all authentication and authorization requests. So if you have another microserver that returns a list of items specific to a user, you need to call the authorization micro server from the list micro server. Lambas would work in a similar manner.

You could use Django for each microserver. It is also common to use Flask as well. You will need a separate data store for each microserver. However, I am under the impression that Django is not typically used to implement Lambdas.

If you are considering going the microserver route, you might also consider a container service to develop/deploy your micro servers. Something based on Kubernetes like OpenShift.

oxr463
  • 151
  • 1
  • 1
  • 11
Robert Baron
  • 1,132
  • 7
  • 10
  • Do you mean "microservice architecture"? That would be more service design related, whereas "serverless" is deployment related. – Jason Capriotti Aug 02 '20 at 20:50