The Quest for Speedy REST

We are working on a project that has a large data set. Normally we don’t have the privilege of knowing the size of the data in advance when we build a new system. Usually it’s created over time so this was a nice challenge.

For the back end we use Django Rest Framework – it’s kinda like a Database API that allows our Vue front end to Create/Read/Update and Delete Data (CRUD) but in this case the speed was too slow so I went looking for answers and here is what I found.

I tried a few solutions.

pRest

https://postgres.rest/

I liked the idea of a Golang server for speed and I have been looking into GoLang as a possible backend language myself as I like the idea of it.

It seemed to work pretty well and the speed was much improved on Django Rest Framework.

But there are some short comings.

  1. It appears to be Dead. Last commit was 2018 and that was a commit looking for funding.
  2. My Go lang skills are NOT up to the task of doing any fixes yet
  3. There are somethings missing. Things PostgREST has.

PostgREST

https://postgres.rest/

I was hesitant to look at this because of the Haskell thing. I have not used Haskell and I have no interest in learning it. (unlike Go I was prepared to get my hands dirty)

The Speed was not as good as pRest but much better than Django Rest Framework so it is a contenter.

Hasura

https://hasura.io/

Hasura has also been on my radar for awhile. Once again the Haskell thing sort of put me off but I decided to give it a try.

I must say I was impressed with the console. And it worked well with my existing Django Rest data model. Including many to many fields.

I have reservations about Graphql. I am not sure why its not a JSON format but I also know JSON is NOT very good for this sort of thing.

Results

TLDR – Spoiler Alert – I went with Hasura

So I ran a test of my dataset that has 9.975 records. Here are the results

Speed (ms)Improvement
Django Rest Framework1232(baseline)
pREST16387%
PostgREST26079%
Hasura23086%
Fetching 10,000 records in one go

As you can see Hasura was faster than PostgREST. I like the idea of a powerful query from the Front end so I am going to go with Hasura. I also like the look of the integrations that may make it easier to develop the apps. I also found the queries run quicker over time. When compiling this post I ran the query and got data in 140ms but then I thought I will restart the server and see if it’s the same result and it was slower (as above). Subsequent running of the same query gave quicker results.

Leave a Comment

Your email address will not be published. Required fields are marked *