|
How to configure my OSQA installation to be as fast as possible? Let's say that everything is open for tweaking. Are there any recommendations? |
|
So, the first thing to optimise / tweak performance is to actually measure the performance. django-debug-toolbar is your friend! You install it on your command line by: Next, open up your settings_local.py file and set:
Save the file and restart apache(or whatever your webserver is). Refresh your website and you will now see the tab on the right hand side for Django Debug Toolbar (http://robhudson.github.com/django-debug-toolbar/) Now you can see and measure various parameters that you would like to tweak: Django Version, Time, Settings, HTTP Headers, Request Vars, SQL, Templates, Signals and Logging.
Use the Django Debug Toolbar to see what the bottleneck is and iterate.
link
This answer is marked "community wiki".
|
|
Just enabled memcached as this post explains. The effort/reward ratio of doing that one single thing must be x50 that of any of the other possibles. Bet 99% of people are happy with this one thing and it takes 4-5 minutes, max. It is a remarkably worthwhile step - congrats!
(08 Dec '11, 11:45)
rickross ♦♦
|
IIS Performance Epic Battle of 2011IIS is the standard where I work so we're trying our best to make it happen. Basic Suggestions
Don't Use PyISAPIeIn general it seems like PyISAPIe is the preferred way to go to serve Django from IIS as it's a prominent in the django docs: We tried it out. Getting PyISAPIe to work is slightly complicated by the fact that you have to compile it yourself if you're using anything later than Python 2.6 at the time of this writing. Unfortunately then we found out it breaks all authentication methods in OSQA (except we didn't check local auth, that might still work). We tried it out and confirmed this behavior also mentioned in comments on this post. It's surely possible to fix but it is over my head. I was able to use our OSQA instance on PyISAPIe before I logged out and performance-wise it seemed comparable to isapi_wsgi, but spinning up the process for the first time was much slower, over 10 seconds usually. Verify NTFS PermissionsMake sure NTFS permissions allow the app pool identity to write inside the main osqa directory. This will allow the default filesystem caching and the python bytecode files (.pyc) to be written to disk. Once the bytecode is generated it takes less time to spin up. At minimum you need write permissions in the Let IIS Serve the Static ContentCreate a virtual directory called “m” that points to the Create a web.config file that looks like this and place it in the skins folder:
This will remove our wild-card mapping for the isapi_wsgi handler and replace it with the IIS static content handler. There’s also static content for the built-in Django admin interface, which can optionally be used. That content will be located where django was installed, in our case Last but not least, the uploaded files folder. Create a virtual directory called “upfiles” and point it to The way to verify whether IIS is handling files there is to watch the response codes. Before IIS was configured to handle them, django was returning 200 response codes every time. Afterwards you should see some 304's. Comparing local requests on my dev box here for static files, IIS serves them around 4x faster. On a loaded server the difference would probably be more dramatic. Memcached on WindowsIt's somewhat difficult to find up-to-date binaries for Windows. If you don't mind running an older version of memcached, then the best choice for deploying memcached to Windows is this little guy called MemCacheD Manager. It includes a 1.2.6 binary and will deploy it for you as a windows service in a few clicks. Heres the best selection of Win32 binaries I could find:
Unfortunately in post 1.2.6 memcached builds the "-d install" option doesn't register the windows service correctly and otherwise doesn't speak to SCM properly, so you lose some of the benefits of managing it as a windows service. If you would like cobble through it and run a newer/64 bit memcached as a service anyway you can stop the service MemCacheD created, drop the newer executable in place over the old one (including pthreadGC2.dll in my case with memcached 1.4.5 64-bit). SCM will report the service didn't start properly even though it did (look for memcached in task manager). Also using the newer executable MemCacheD Manager won't work afterwards (it likes 1.2.6 though). Be mindful when you start the service SCM thinks it fails, so when you start it subsequent times it will keep spawning more memcached processes which don't do anything. So it seems the best way to go if you have the flexibility and don't want to run an outdated memcached build is to stand up a separate *nix machine and run memcached there. There is something called Membase Server for windows (looks nice), but apparently django can't read from it correctly. There's also a django in-memory cache but it's less reliable than memcached (What happens when your process is killed after idling? etc.) and won't share data cross-process. Having memcached running opens up another nice option. You can set up write-through session caching then by changing this line in settings_local.py:
You should only use session caching with memcached. Prefer the cached_db backend over the cache backend for reliability. Use SQL Server on WindowsGetting OSQA working on SQL Server did seem to make a difference but I'm not sure what specifically is working better. Our SQL Server is a dedicated box so of course that will make a difference, but I'm also fairly certain that the ADO provider does connection pooling for you, so that is also helpful. PrerequisitesInstall django-mssql from trunk by running Set your connection string in settings_local.py like so:
SQL Server Compatibility HacksOSQA has some problems inserting and updating things (these would be critical features) when speaking to SQL Server, and it could be a problem with django-mssql, South, or OSQA - or all three... Inserting things won’t work because some columns with unique indexes are set to null initially (for unique zero-to-many relationships). By default SQL Server will complain if there is more than one record with this initial null value, because of the way it treats nullity (as a value versus “unknown”). So we have to change that unique index to be a filtered unique index so multiple null values can exist. Filtered indexes are a new feature in SQL Server 2008. In earlier versions the fix is to create a computed column that coalesces null values with a new unique value, and then define your unique constraint on that... So far we’ve only identified one column affected by this problem,
Updating things won’t work because the ORM-generated SQL code for update statements sometimes includes a statement that sets the identity column to the same value it was. This is legal to do in MySQL but SQL Server doesn’t like it. The fix is to alter OSQA code to exclude identity columns from the list of columns to update so that django-mssql won’t emit SQL statements for them. To fix this, fire up your trusty text editor and open the OSQA base model, which is found at
This adds a type-check when building lists of update fields to exclude something called AutoField, which is a Django type for auto-incrementing (Identity) columns. Further ReadingI've stumbled on many articles but don't have time right now to pull out details:
Just in case anybody else would think of trying: We tested with IIS7 - Postgresql, WSGI, ThreadPoolHandler() but performance was unacceptably slow. See this thread: http://meta.osqa.net/questions/4955/install-osqa-on-windows-2008-with-sql-server-2008?page=1#10555 Windows is clearly not an option, until somebody figures out how to deploy OSQA on IIS with a Windows-ready database system like SQL Server.
(24 Nov '11, 09:45)
Vincent Buck
I'm still trying to dial in the optimal configuration for IIS - not willing to give up yet! Today I looked at the django-debug-toolbar and surprisingly MySQL (a local instance) was performing well according to it, but maybe the measurement isn't capturing the whole round-trip.
(28 Nov '11, 20:22)
HAL9000
Do you have any evidence to accuse Helicon Zoo being slow? Really, we always try to do our best to make our product as fast as possible, and performance is very important for us. According to our tests Helicon Zoo outperforms PyISAPIe more than 3 times on a transport level! Here is an article link: http://www.helicontech.com/articles/running-django-on-windows-with-performance-tests/ Taking into account that so many factors are involved with OSQA I can admit that some installations may be slower, which generally depends on database used. Can you please contact me at support@helicontech.com with your tests details, as we really want to reproduce your tests locally. If there is something in Helicon Zoo that needs to be improved, we are eager to do this to clear out our name. Thank you!
(20 Jan, 10:57)
govorunov
DZone and the OSQA project have no opinion whatever regarding Helicon Zoo. We don't feel this question about optimizing OSQA performance is an appropriate context for third parties to argue about Helicon Zoo, and we respectfully ask those of you who wish to argue to find another place to do so.
(20 Jan, 11:35)
rickross ♦♦
@govorunov i will follow up with you at your support email about this an redact my statement about zoo. Will add details about our server to the answer. we did not carry out adequate testing to make this claim about the helicon zoo module itself, but because the revision of osqa included is very old, and because the helicon zoo stack also includes mysql which according to this article wasn't performing well on windows, I made this generalization. It is most definitely a combination of things, but I can say it was slow for us. I would be willing to try Helicon Zoo again, if there's a way to deploy the fcgi handler separate from the osqa source.
(20 Jan, 14:27)
HAL9000
rickross, sorry, no offense where meant. I simply want to find a resolution. And if something in the combination of Helicon Zoo, OSQA, MySQL and anything else make it slower, I am willing to find why and provide a fix. HAL9000, thank you. Waiting for your details. Isn't version 0.9.0 of OSQA available from Zoo repository latest one?
(20 Jan, 14:38)
govorunov
@govorunov meta.osqa.net is running trunk generally speaking. browsing their repo there was an understated RC1 release you could look at using. OSQA folks have been saying trunk is OK to use lately, probably because trunk has many fixes to the beta and their v1 release isn't going to be ready for a while. We had problems with 0.9.0. As of rev 1204 it's working well for us.
(20 Jan, 14:44)
HAL9000
showing 5 of 7
show 2 more comments
|

Good question +1 :)