We have a server running a Python application in Apache with mod_wsgi. In httpd.conf we configured 4 processes to run this application, each with multiple threads.
This configuration caused us some troubles. We extensively used memory to cache some results from very complicated and time-consuming computation and also some key-value pairs for efficient reading, and since different processes don’t share memory, we have multiple memory copies of the same data. That is, we need around 4x memory of the cache size. Of course, this can be solved by using something like memcached.
Another problem is logging. We are using Python’s built-in logging module to do this job (we needed extra logging besides Apache’s accesslog). At first we used the basic FileHandler and everything seemed OK. Later we decided to use TimedRotatingFileHandler to rotate the log at midnight so that we can analyze the logs daily. But on the second day, we found that the previous day’s log was missing. For example, today is 2011-08-10 and we expect to see yesterday’s log in file “customlog-2011-08-09”, but this file is full of today’s log entries! Both files “customlog” (the non-rotated file generated today) and “customlog-2011-08-09” are growing, which means that they are both being appended by processes.
Continue reading “Python Logging from Multiple Processes”
There are many articles if you Google for “OpenVPN setup”. Most of them teach you how to install OpenVPN on various operating systems and how to write server configuration files. But while some people are looking for solutions of getting into a LAN (in an office, for example) from outside, I think many are seeking a way of breaking through some network restrictions, or creating a secure tunnel to reach the Internet.
In the latter scenario, just getting OpenVPN daemon up running isn’t enough. What we need to do next is setting up IP traffic forwarding and set iptables rules to accept the traffic. Actually my favourate tutorial is this one:
Continue reading “Setting Up OpenVPN Server in Fedora 14”
Many sites use Facebook Connect today, hoping to share the popularity of Facebook, pulling Facebook users’ profile/feed, and publishing their own site-generated contents to users’ feed/wall. So most Facebook Graph tutorials, including Facebook’s own documentation, tell us how to add Facebook Connect button to our sites, how to set the redirect URL, how to grab the access token, and how to request for users’ privacy.
But I wanted to rely on Facebook instead of implementing my own user login/registration processes. I’m still doing investigation and I don’t have a working example yet so this post is just my rough thoughts. I will come back and revise it when I get the implementation experience.
Continue reading “Using Facebook (and Other Sites) as User Authentication System”
Yesterday a friend told me that he could not use wget to download a web page, which was protected by HTTP authentication.
HTTP/1.1 has two auth methods – Basic and Digest. Basic auth just sends the username and password in plain text and Digest sends a hashed password.
Basically the process involves two round trips. The client first requests for the resource and the server returns a 401 response so the client now knows that authentication is required (The server tells the auth method, Basic or Digest, in the response header). Then the client sends the same request again, but adding an “Authorization” header field this time. The server checks this header line and if authentication is successful, responses with the correct resource and a 200 status code. But if authentication fails, it will send another 401 response. Normally the client stops trying and tells user about the failure.
Continue reading “wget and HTTP Digest Authentication”
Although many books are already available for read on Kindle, some books still don’t have a Kindle version.
And for some books with lots of graphs/tables are not very well organized on Kindle. Microeconomics is an example. The Kindle version’s price is nearly the same high as paperback, so why do people buy the Kindle version? Sure it’s way lighter, but the type setting is frustrating, according to some of the product reviews.
But after being used to reading on a Kindle, the problem with reading this paperback version is that it’s too heavy to hold it with hands! So I though about a book stand or book holder and actually there are some products out there. Some of them seem promising:
Of course most of the book stands mentioned above also support Kindle/iPad.
There used to be a time when it was really painful to start Firefox on my MacBook. It seemed to start normally but soon the window became unresponsive. Usually it took several minutes before I can use Firefox to browse web sites – really annoying. I searched but found people facing the same problem without a solution or response from Firefox developers (here and here).
In the mean time I was quite confused by Firefox frequently asking me to allow its access to some font file on the bootcamp partition – how does Firefox know that I installed a Windows system? More importantly, why does Firefox want to examine this just for a font?
At first I didn’t think much and always allowed it to access the fonts but one day I finally chose “Don’t allow” and checked the “Do not ask me again” box. I don’t know if that is the solution but several days later I noticed that Firefox started as quickly as before!
If you’re suffering the same problem, and also asked by Firefox the same question, please try this and comment below. But I don’t know what to do if you already checked the “Do not ask” box and clicked “Allow”…