Help troubleshooting multi-domain app!

39 views
Skip to first unread message

Prateek Malhotra

unread,
Jun 11, 2012, 5:06:10 PM6/11/12
to google-a...@googlegroups.com
I have an app with multiple domains setup for it. Inside the app, I use the request.host_url value to help drive some logic of the website as well as the base URL for all links on the page. We discovered that we'll randomly land on a page from one domain yet we'll see it linking to another domain that's still part of our account. This is obviously unsettling.

I tracked one such instance in our logs and found something odd with the data that was logged:

I visited http://www.DOMAINA.com/XXXXXX?categoryID=11116 and found this in the headers:

"GET /XXXXXXX?categoryId=11116 HTTP/1.1" 200 7396 "http://www.DOMAINA.com/XXXXXXX?categoryId=4733" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5" "www.DOMAINB.com" ms=1033 cpu_ms=327 api_cpu_ms=0

As you can see, there log gives a random full URL requested under DOMAINA.com, but all links and such are generated on the page as if the request originated from DOMAINB.com. I have threadsafe enabled on this app so I wonder if it has to do with an instance handling two request from two separate domains simultaneously and thus crossing over data between requests. The previous request that the instance served to DOMAINB.com was 3 seconds before the the request I've shown above. There were also 10 other requests on the various other domains between them.

Is this due to something incorrect in my code and utilizing threadsafe? I'm confused as to why the headers found in the log lists two different domains and that the request portion of the URL is accurate in one spot but not the other. I would appreciate any advice in tracking down this issue, nothing in the code seems like it should be causing this kind of issue.

Prateek Malhotra

unread,
Jun 11, 2012, 5:13:52 PM6/11/12
to google-a...@googlegroups.com
I just realized the entry of DOMAINA.COM was set as the "referring URL". I think it must be caused by something in my code then and handling multiple request from varying domains with thread safe enabled.

Thank you,
Prateek

Brandon Wirtz

unread,
Jun 11, 2012, 5:21:29 PM6/11/12
to google-a...@googlegroups.com

We have a few hundred domains running on an app, it seems to work just fine. Thread safe enabled.  Are you sure you aren’t doing some caching on your end that needs to be domain aware and is not?

 

Prateek Malhotra

unread,
Jun 12, 2012, 9:55:18 AM6/12/12
to google-a...@googlegroups.com
Wasn't a caching issue (unless Google's Edge cache isn't domain aware). Was a mixture of using class-based views, lazy loading, and not understanding the underlying framework execution path fully. A little more digging and I found a thread-safe way to utilize class based views with lazy loading.

The framework was never instantiating a new instance of the class to handle each request, instead recycling a previous instance (this has its pros/cons). While handling requests, it would update the request object in the instance of the class-based view, so if a second request came in before the first request was done executing, the request object was updated to the second requests' and the first request completed execution with it. There is a way to have the framework create new instances of the class for each request which I've now switched to.

Thank you for the advice, my apologies for not realizing my mistake before posting.

-Prateek
Reply all
Reply to author
Forward
0 new messages