I have a Silverspripe Page with a sports Liveticker and a RestAPI for iOS and Android App. Every call I make that is Not in the static cache makes some System calls setting a filelock.
I have this function in my jsonapi Controller:
function image(){
if($this->request->param('ID')){
$id = $this->request->param('ID');
if($id > 0){
$image = Image::get()->distinct(false)->byID($id);
if(is_object($image) && $image->exists()){
$filetype = $image->getExtension();
$width = $this->getRequest()->getVar("width");
$height = $this->getRequest()->getVar("height");
if(isset($width) && isset($height)){
$url = $image->croppedImage($width,$height)->URL;
} elseif(isset($width)){
if($width == 0){
$url = $image->URL;
} else{
$url = $image->setWidth($width)->URL;
//Debug::log("setWidth URL: ".$url);
}
} else{
$url = $image->setWidth(1600)->URL;
}
header("Content-type: image/{$filetype}");
header("Cache-Control: public, max-age=2678400");
header('Content-Length: ' . filesize(Director::baseFolder().$url));
readfile(Director::baseFolder().$url);
die();
}
}
return null;
} else{
return null;
}
}
When I call it even with ID=0 Silverstripe sets these Filelocks. When 200 Clients at the same time calling it my server goes down. 100% CPU usage with systemcalls like this:
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
fcntl(22, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
It's files like _ss_environment.php ect. (probably every .php thats in use. So the Cliens are blocking each other with all these locks. How can I disable it? Is there some sort of global Variable to disable unneeded filelocks? Or do I have to change this in the core? Where can I find it?