WebFaction
Community site: login faq

Hi,

I'm about to release a Django based facebook app, which allows users to create personal 'looks' and other users to comment on these looks (either through the app, or through the wall post the app creates). I have an app wall of sorts on the main page where all the popular looks are shown. The issue I'm facing is that I can't hit the facebook graph api while showing the looks on the main page to show the number of comments, because the page becomes too slow then. I wanted some way to know the number of comments posted on each look before showing them on the apps main page/wall. I was thinking of writing a script that'll go to each look in my db and hit the facebook graph api and find the number of comments posted through the wall post and save it in my db and run that every minute on a cron job. I was wondering...if the number of looks becomes pretty high down the line...would this use up a lot of...er..bandwidth/computational power? lol..sorry, I have no idea how hosting works and stuff!

Sorry for the long post!

asked 19 May '12, 00:52

iman453
491527
accept rate: 0%

edited 19 May '12, 03:11


At some point any application will reach its number of concurrent users.

There is not a set process to determine what that limit is, since each app is unique.

The general idea is to build the app as efficient as possible, than apply load against the app using testing tools (like 'ab') and than monitoring the CPU/RAM/Disk/Bandwidth the app is using making adjustments to code where needed.

You the developer will need to have a certain understanding of The web in general, Django, Python, Apache and Mod_wsgi to maintain and scale a Django application. Reading the official documentation for all these projects and absorbing it (as painful as it can be) is a good idea.

I will note some of the important things you will need to know to start the process. There is a lot of research you will need to do beyond this, it should be a good start however.

A few important documents to read for background would be this one and this one for mod_wsgi and this one for Django Query sets.

These commands can be used to isolate RAM and CPU usage,

# replace 'user' with your username. 
$ ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}' 
$ ps -u user -o rss,command 
$ htop -u user

Our official documentation on this may be found here.

Using a web-browser with developer tools, such as Google Chrome, and understanding those tools will allow you to perform tests with the JavaScript and other resource loading tests.

Lastly you can use the 'ab' tool to perform many hits against a certain URL and receive a report for comparison.

# replace domain.com with your domain
$ ab -n 100 -c 10 http://domain.com/
$ ab --help
permanent link

answered 19 May '12, 01:31

johns
5.4k312
accept rate: 23%

edited 19 May '12, 01:32

Thank you for your detailed reply! I'll definitely go through all that stuff. Um, I actually forgot to enter the main part of my question in my rant....so I wanted to run the script in a cron job that'll run every minute. That's probably not a good development practice right?

(19 May '12, 03:13) iman453

This depends on what the cronjob will be doing - there are certainly cases where running a cronjob every minute is acceptable.

(19 May '12, 03:17) todork
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×81

question asked: 19 May '12, 00:52

question was seen: 2,828 times

last updated: 19 May '12, 03:17

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM