Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Best practices for calling an external service in a Django app
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thomas Orozco  
View profile  
 More options May 11 2012, 4:50 am
From: Thomas Orozco <g.orozco.tho...@gmail.com>
Date: Fri, 11 May 2012 10:50:01 +0200
Local: Fri, May 11 2012 4:50 am
Subject: Best practices for calling an external service in a Django app

Hi,

Here's my situation: one of my views needs to call an external service
(through a socket ; actually the said service is on the same server).

I don't even need to know about the service's response as I'll inquire
about it asynchronously in an effort to avoid delay on the user's end.

What are the best practices here ?
Should I open a socket connection each time I want to access the service?
Should I keep one open all the time in a separate thread?

Thanks in advance,

Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcin Tustin  
View profile  
 More options May 11 2012, 5:17 am
From: Marcin Tustin <marcin.tus...@gmail.com>
Date: Fri, 11 May 2012 10:17:33 +0100
Local: Fri, May 11 2012 5:17 am
Subject: Re: Best practices for calling an external service in a Django app

I use a celery task to make this sort of job asynchronous. The task makes a
new connection to the "remote" (same server) service each time. This proves
to be sufficiently fast.

If you are making a lot of requests, the overhead of making new connections
may prove to be significant. I wouldn't anticipate this unless you are
making a new request more frequently than perhaps once a second (and even
then, I would wait and see what performance was like).

On Fri, May 11, 2012 at 9:50 AM, Thomas Orozco <g.orozco.tho...@gmail.com>wrote:

--
Marcin Tustin
Tel: 07773 787 105

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Orozco  
View profile  
 More options May 11 2012, 6:17 am
From: Thomas Orozco <g.orozco.tho...@gmail.com>
Date: Fri, 11 May 2012 12:17:48 +0200
Local: Fri, May 11 2012 6:17 am
Subject: Re: Best practices for calling an external service in a Django app

Thanks for the information!

Using celery was my first idea too, but here it is not practical as I'll be
transferring sensitive information through the socket and I'd rather avoid
having hanging around in the Celery queue.

So I guess opening the socket from inside the view code and then closing it
would be OK?
 Le 11 mai 2012 11:17, "Marcin Tustin" <marcin.tus...@gmail.com> a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcin Tustin  
View profile  
 More options May 11 2012, 6:41 am
From: Marcin Tustin <marcin.tus...@gmail.com>
Date: Fri, 11 May 2012 11:41:00 +0100
Subject: Re: Best practices for calling an external service in a Django app

The thing is, you will then be doing it synchronously, because python's
global interpreter lock means that threads are never really parallel.

To avoid having the sensitive data in your celery queues, have your task
retrieve the sensitive data from the database (if that's where its coming
from). If it's coming from the frontend, then you are going to have to
store it somewhere if you want to do this asynchronously. I doubt that
poses such a great additional security risk, as long as it all remains on
the same machine, especially if you use a volatile celery backend (e.g.
redis with no persistence enabled).

If you are doing it synchronously, then you may want to consider if the
client can pass you the data via an ajax call from a web worker, which will
improve the user perception of performance.

On Fri, May 11, 2012 at 11:17 AM, Thomas Orozco
<g.orozco.tho...@gmail.com>wrote:

--
Marcin Tustin
Tel: 07773 787 105

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »