Any django-converts ? Best practices, comments, observations

609 views
Skip to first unread message

Sankar

unread,
Nov 30, 2015, 6:13:15 AM11/30/15
to golang-nuts
We are considering Golang for a new project. Until now, we have been a total django shop. Has anyone made a migration from django to golang ? Which frameworks have you used / recommend ? Any tips/pointers etc. ? The application will be a webservice, running on beanstalk (or EC2), saving / pulling data from Amazon DynamoDB. Will use rabbitmq or SQS as well.

We are currently in evaluation stage evaluating both Python and Go. Amazon Lamba directly supports Python, which is a huge plus. In the past, we have found that our team relies heavily on the ORM and Migrate facilities provided by the django. So we wanted to find out how difficult / easy it was for people who migrated from django and know of the experience.

Thanks.

Sankar

Eric Johnson

unread,
Nov 30, 2015, 2:10:18 PM11/30/15
to golang-nuts
Several thoughts:


On Monday, November 30, 2015 at 3:13:15 AM UTC-8, Sankar wrote:
We are considering Golang for a new project. Until now, we have been a total django shop. Has anyone made a migration from django to golang ?

I have not. I've poked around with a few Django projects, so I have some perspective. Django makes a lot of assumptions about how you're implementing, which has, in my experience let to interesting constraints on operating system versions, hosting configurations, and more.
 
Which frameworks have you used / recommend ?

In general, this list recommends starting with:

Not a typo. Use the standard library. If you get complicated / sophisticated URL patterns, you might try https://github.com/gorilla/mux
 
Any tips/pointers etc. ?

Start simple, and build up from there.
 
The application will be a webservice, running on beanstalk (or EC2), saving / pulling data from Amazon DynamoDB. Will use rabbitmq or SQS as well.

We are currently in evaluation stage evaluating both Python and Go. Amazon Lamba directly supports Python, which is a huge plus.

 
In the past, we have found that our team relies heavily on the ORM and Migrate facilities provided by the django.

You should even see if you can get by without an ORM. If you are only targeting a single database, then ORM won't really get you far, and will introduce a layer of indirection that can trigger performance issues, and difficulty reasoning about the best way to accomplish something. If you're not planning on migrating between database implementations, then just bind to one. If you do change later, it isn't that hard to provide overrides for specific databases, should you decide you need to support multiples.

I know with my experience with the Django ORM, I had a huge problem with performance that wasn't easy to resolve, because various object relationships required a save (and commit) before adding further objects. Without the required commit - with direct access to the database, I could have taken what turned into hundreds or thousands of commits, and done the entire operation in one transaction, thus making the entire operation take less than a tenth of the time.

As for the migration question, there's a very simple pattern to follow - store the "version" of your database schema in the database. Whenever you change your database, write the appropriate SQL statement to make the change as well. When your app starts up, run the code to migrate the database from the old version to the new, if any migration is required.
 
So we wanted to find out how difficult / easy it was for people who migrated from django and know of the experience.

My suggestion is to look at a large-ish open source project that might be similar to your requirements, and poke around the code, see whether it makes sense to you.

Eric.

Shawn Milochik

unread,
Nov 30, 2015, 2:21:55 PM11/30/15
to golang-nuts
As someone with 6+ years of full-time Django experience, attendee of four DjangoCons, small-time contributor to Django, and once very active on the django-users mailing list, I agree with everything Eric said. Please take his advice. 

Given the choice, I'd never use Django again. If I had to do a Web app in Python, I'd use Flask. If you're interested in why, search for "I have to agree with Owein here" on this page and read the comment by Trey: http://comments.gmane.org/gmane.comp.web.flask.general/5237

To augment his migration suggestion, check out sql-migrate. It's written in Go and can be used as a library, but it can also be used stand-alone with a non-Go application, such as a Django project:


sa...@softinio.com

unread,
Nov 30, 2015, 3:19:15 PM11/30/15
to golang-nuts
I have used Django (alot) and golang more recently. 

Avoid using any frameworks with golang. Try to create your own world with the standard library and like Eric said use light libraries such as https://github.com/gorilla/mux and https://github.com/jmoiron/sqlx 

If you really like django/rails type of framework, you may want to look at Elixir Programming language / Phoenix Framework instead of golang: http://www.phoenixframework.org/
Reply all
Reply to author
Forward
0 new messages