2009年5月10日日曜日

issue: image broken

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク

Some times images may broken. I invastigate it. Current suspected cause is cache expiration mismatch between mod_mem_cache and etag.

First is by FireFox, second is by Google Chrome, since Google Chrome cache is empty, see no problem with code 200.

This is access log for O.K.

192.168.0.10 - - [10/May/2009:16:35:52 +0900] "GET /image?width=400&format=png&height=300&css=kotobuki&gnubgid=sPPgAwLgc4fBAA%3AcInpACAAEAAA HTTP/1.1" 200 14782
192.168.0.10 - - [10/May/2009:16:53:34 +0900] "GET /image?width=400&format=png&height=300&css=kotobuki&gnubgid=sPPgAwLgc4fBAA%3AcInpACAAEAAA HTTP/1.1" 200 14782

This is access_log for broken

192.168.0.10 - - [10/May/2009:16:35:52 +0900] "GET /image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA HTTP/1.1" 304 -
192.168.0.10 - - [10/May/2009:16:53:34 +0900] "GET /image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA HTTP/1.1" 200 14379

I see the HTTP server returning 304 code.

Here is cacheing log.

[Thu May 07 16:30:14 2009] [info] mem_cache: Cached url: http://image.backgammonbase.com:80/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
[Fri May 08 02:46:01 2009] [info] mem_cache: Cached url: http://image.backgammonbase.com:80/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
[Fri May 08 21:06:31 2009] [info] mem_cache: Cached url: http://image.backgammonbase.com:80/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
[Sun May 10 10:54:40 2009] [info] mem_cache: Cached url: http://image.backgammonbase.com:80/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
[Sun May 10 16:53:34 2009] [info] mem_cache: Cached url: http://image.backgammonbase.com:80/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
[Sun May 10 17:31:18 2009] [info] mem_cache: Cached url: http://image.backgammonbase.com:80/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA


so, I checked FireFox disk cache with about:cache?device=disk

Key: http://image.backgammonbase.com/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
Data size: 0 bytes
Fetch count: 1
Last modified: 2009-05-10 16:35:48
Expires: 1970-01-01 09:00:00

Oooops! broken entry is there. Well, why it happend?

Let see other OK cases.

Key: http://image.backgammonbase.com/image?width=400&format=png&height=300&css=kotobuki&gnubgid=jOfgCQIzzpEBMA%3AMAHgAAAACAAA
Data size: 14727 bytes
Fetch count: 1
Last modified: 2009-05-10 16:30:18
Expires: 2009-05-10 17:29:54

Some thing wrong with:

  • Expires goes wrong.

  • Data size is 0 byte



Note:
reload the page, images are generated again and it would be showing OK.

I checked content of cache with about:cache-entry?client=HTTP&sb=1&key=http://image.backgammonbase.com/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA, and found 304 respnse itself is cached... ouch.

key: http://image.backgammonbase.com/image?width=400&format=png&height=300&css=kotobuki&gnubgid=GzuzAQC22wTgAA%3AcInlACAAEAAA
fetch count: 2
last fetched: 2009-05-10 17:19:43
last modified: 2009-05-10 16:35:48
expires: 1970-01-01 09:00:00
Data size: 0
file on disk: C:\Documents and Settings\nori\Local Settings\Application Data\Mozilla\Firefox\Profiles\3url37yt.default\Cache\DC9DBB73d01
Security: This document does not have any security info associated with it.
Client: HTTP
request-method: GET
response-head: HTTP/1.1 304 Not modified
Date: Sun, 10 May 2009 07:35:52 GMT
Server: CherryPy/2.3.0
Cache-Control: public


With google Chrome, it is possible to reproduce problem by pre-requesting page with FireFox, which makes put items in server side cache(?).

In my understanding of this problem is:

  1. There is two or more Apache worker process with mem_cache enabled

  2. process A receives request and cache it on mem.

  3. another process B receives request and got 304 from python cgi, and returns it.
    I need to check what header apache give to python cgi.



Well I hacked mpm.conf in following way: by putting ServerLimit 1, make sure there is only one handling process. I wish to have a feature which binds NameVirtualHost and process, i.e. one prcess on one name, having mem cache for it.

<IfModule worker.c>
StartServers 1
ServerLimit 1
#for mem caceh share
# to stop wrong 304 res for 200 should be
MinSpareThreads 16
MaxSpareThreads 32
MaxRequestsPerChild 0
ThreadLimit 512
ThreadsPerChild 512
MaxClients 512
</IfModule>


References:
apache manual, http://blog.as-is.net/2007/02/modcache.html

0 件のコメント: