Make object server's caching more configurable.
The object server had a constant KEEP_CACHE_SIZE = 5*1024*1024; unauthenticated GET requests for files smaller than KEEP_CACHE_SIZE would not evict the file from the kernel's buffer cache after it was read from disk. Now that hardcoded constant is a configuration parameter ("keep_cache_size"), and now there is also another parameter called "keep_cache_private". If set, then both authenticated and unauthenticated GET requests for small files will not evict the data from the buffer cache. The default values are 5 MiB and False, respectively, so the default behavior is the same. Bonus: the "mb_per_sync" parameter is now documented in the deployment guide. Change-Id: I9a11dbe861f4c23535c6aa82a9111a6fe2db2a59
This commit is contained in:
parent
f7757e4ebf
commit
28cd9b2da8
@ -254,6 +254,10 @@ disk_chunk_size 65536 Size of chunks to read/write to disk
|
|||||||
max_upload_time 86400 Maximum time allowed to upload an object
|
max_upload_time 86400 Maximum time allowed to upload an object
|
||||||
slow 0 If > 0, Minimum time in seconds for a PUT
|
slow 0 If > 0, Minimum time in seconds for a PUT
|
||||||
or DELETE request to complete
|
or DELETE request to complete
|
||||||
|
mb_per_sync 512 On PUT requests, sync file every n MB
|
||||||
|
keep_cache_size 5242880 Largest object size to keep in buffer cache
|
||||||
|
keep_cache_private false Allow non-public objects to stay in
|
||||||
|
kernel's buffer cache
|
||||||
================== ============= ===========================================
|
================== ============= ===========================================
|
||||||
|
|
||||||
[object-replicator]
|
[object-replicator]
|
||||||
|
@ -35,6 +35,11 @@ use = egg:swift#object
|
|||||||
# disk_chunk_size = 65536
|
# disk_chunk_size = 65536
|
||||||
# max_upload_time = 86400
|
# max_upload_time = 86400
|
||||||
# slow = 0
|
# slow = 0
|
||||||
|
# Objects smaller than this are not evicted from the buffercache once read
|
||||||
|
# keep_cache_size = 5424880
|
||||||
|
# If true, objects for authenticated GET requests may be kept in buffer cache
|
||||||
|
# if small enough
|
||||||
|
# keep_cache_private = False
|
||||||
# on PUTs, sync data every n MB
|
# on PUTs, sync data every n MB
|
||||||
# mb_per_sync = 512
|
# mb_per_sync = 512
|
||||||
# Comma separated list of headers that can be set in metadata on an object.
|
# Comma separated list of headers that can be set in metadata on an object.
|
||||||
|
@ -37,7 +37,8 @@ from eventlet import sleep, Timeout, tpool
|
|||||||
|
|
||||||
from swift.common.utils import mkdirs, normalize_timestamp, public, \
|
from swift.common.utils import mkdirs, normalize_timestamp, public, \
|
||||||
storage_directory, hash_path, renamer, fallocate, \
|
storage_directory, hash_path, renamer, fallocate, \
|
||||||
split_path, drop_buffer_cache, get_logger, write_pickle
|
split_path, drop_buffer_cache, get_logger, write_pickle, \
|
||||||
|
TRUE_VALUES
|
||||||
from swift.common.bufferedhttp import http_connect
|
from swift.common.bufferedhttp import http_connect
|
||||||
from swift.common.constraints import check_object_creation, check_mount, \
|
from swift.common.constraints import check_object_creation, check_mount, \
|
||||||
check_float, check_utf8
|
check_float, check_utf8
|
||||||
@ -54,7 +55,6 @@ ASYNCDIR = 'async_pending'
|
|||||||
PICKLE_PROTOCOL = 2
|
PICKLE_PROTOCOL = 2
|
||||||
METADATA_KEY = 'user.swift.metadata'
|
METADATA_KEY = 'user.swift.metadata'
|
||||||
MAX_OBJECT_NAME_LENGTH = 1024
|
MAX_OBJECT_NAME_LENGTH = 1024
|
||||||
KEEP_CACHE_SIZE = (5 * 1024 * 1024)
|
|
||||||
# keep these lower-case
|
# keep these lower-case
|
||||||
DISALLOWED_HEADERS = set('content-length content-type deleted etag'.split())
|
DISALLOWED_HEADERS = set('content-length content-type deleted etag'.split())
|
||||||
|
|
||||||
@ -361,11 +361,14 @@ class ObjectController(object):
|
|||||||
self.logger = get_logger(conf, log_route='object-server')
|
self.logger = get_logger(conf, log_route='object-server')
|
||||||
self.devices = conf.get('devices', '/srv/node/')
|
self.devices = conf.get('devices', '/srv/node/')
|
||||||
self.mount_check = conf.get('mount_check', 'true').lower() in \
|
self.mount_check = conf.get('mount_check', 'true').lower() in \
|
||||||
('true', 't', '1', 'on', 'yes', 'y')
|
TRUE_VALUES
|
||||||
self.node_timeout = int(conf.get('node_timeout', 3))
|
self.node_timeout = int(conf.get('node_timeout', 3))
|
||||||
self.conn_timeout = float(conf.get('conn_timeout', 0.5))
|
self.conn_timeout = float(conf.get('conn_timeout', 0.5))
|
||||||
self.disk_chunk_size = int(conf.get('disk_chunk_size', 65536))
|
self.disk_chunk_size = int(conf.get('disk_chunk_size', 65536))
|
||||||
self.network_chunk_size = int(conf.get('network_chunk_size', 65536))
|
self.network_chunk_size = int(conf.get('network_chunk_size', 65536))
|
||||||
|
self.keep_cache_size = int(conf.get('keep_cache_size', 5242880))
|
||||||
|
self.keep_cache_private = \
|
||||||
|
conf.get('keep_cache_private', 'false').lower() in TRUE_VALUES
|
||||||
self.log_requests = conf.get('log_requests', 't')[:1].lower() == 't'
|
self.log_requests = conf.get('log_requests', 't')[:1].lower() == 't'
|
||||||
self.max_upload_time = int(conf.get('max_upload_time', 86400))
|
self.max_upload_time = int(conf.get('max_upload_time', 86400))
|
||||||
self.slow = int(conf.get('slow', 0))
|
self.slow = int(conf.get('slow', 0))
|
||||||
@ -722,9 +725,10 @@ class ObjectController(object):
|
|||||||
response.etag = file.metadata['ETag']
|
response.etag = file.metadata['ETag']
|
||||||
response.last_modified = float(file.metadata['X-Timestamp'])
|
response.last_modified = float(file.metadata['X-Timestamp'])
|
||||||
response.content_length = file_size
|
response.content_length = file_size
|
||||||
if response.content_length < KEEP_CACHE_SIZE and \
|
if response.content_length < self.keep_cache_size and \
|
||||||
'X-Auth-Token' not in request.headers and \
|
(self.keep_cache_private or
|
||||||
'X-Storage-Token' not in request.headers:
|
('X-Auth-Token' not in request.headers and
|
||||||
|
'X-Storage-Token' not in request.headers)):
|
||||||
file.keep_cache = True
|
file.keep_cache = True
|
||||||
if 'Content-Encoding' in file.metadata:
|
if 'Content-Encoding' in file.metadata:
|
||||||
response.content_encoding = file.metadata['Content-Encoding']
|
response.content_encoding = file.metadata['Content-Encoding']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user