由于 "too much memory",App Engine 进程随机终止
App Engine Process randomly terminated because of "too much memory"
在过去的一年里,我一直在使用 google App Engine 制作 PDF,然后将它们输出到页面上。直到今天,他们一直在完美地工作。
现在,我收到以下错误 - 并非总是如此,但可能有大约 40% 的请求返回时出现了关于它被终止的 500 错误。
有谁知道为什么会发生这种情况以及如何避免这种情况?
While handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application.
这是我的脚本。有时我使用 $pdf->MemImage();
向其中添加图像
或者我用 $pdf->Cell()
添加文本,但这是唯一的区别。
<?php
define('FPDF_FONTPATH','lib/fpdi/fonts');
require_once('lib/fpdf.php');
require_once('lib/fpdi/fpdi.php');
$pdfPath = file_get_contents("gs://bucket/template.pdf");
$temp_id = "12345";
$max_pages = 5;
//put the pdf image into a temp directory in google drive
$object_url = "gs://bucket2/template.pdf";
file_put_contents($object_url, $pdfPath);
//Start the FPDI
$pdf = new FPDI('P', 'pt');
$pdf->SetAutoPageBreak(false);
//Set the source PDF file
$source_file = $pdf->setSourceFile("gs://bucket2/template.pdf");
for($page_count = 1; $page_count <= $max_pages; $page_count++)
{
//Import the first page of the file
$tppl = $pdf->importPage($page_count);
$pdf->AddPage();
//get size of pdf page
$size = $pdf->getTemplateSize($tppl);
$pdf->useTemplate($tppl, null, null, $size['w'], $size['h'], true);
}
header('Content-Type: application/pdf');
$pdf->Output("template.pdf", "I");
unlink("gs://bucket2/template.pdf");
?>
我通过更新实例 class 和 app.yaml
中的基本缩放解决了这个问题。这只是实验,可能需要根据用例而有所不同,但它确实为我解决了问题。感谢所有在上述评论中提供帮助的人。
application: <APPLICATION NAME>
version: 1
runtime: php55
api_version: 1
instance_class: B2
basic_scaling:
max_instances: 5
在过去的一年里,我一直在使用 google App Engine 制作 PDF,然后将它们输出到页面上。直到今天,他们一直在完美地工作。
现在,我收到以下错误 - 并非总是如此,但可能有大约 40% 的请求返回时出现了关于它被终止的 500 错误。
有谁知道为什么会发生这种情况以及如何避免这种情况?
While handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application.
这是我的脚本。有时我使用 $pdf->MemImage();
向其中添加图像
或者我用 $pdf->Cell()
添加文本,但这是唯一的区别。
<?php
define('FPDF_FONTPATH','lib/fpdi/fonts');
require_once('lib/fpdf.php');
require_once('lib/fpdi/fpdi.php');
$pdfPath = file_get_contents("gs://bucket/template.pdf");
$temp_id = "12345";
$max_pages = 5;
//put the pdf image into a temp directory in google drive
$object_url = "gs://bucket2/template.pdf";
file_put_contents($object_url, $pdfPath);
//Start the FPDI
$pdf = new FPDI('P', 'pt');
$pdf->SetAutoPageBreak(false);
//Set the source PDF file
$source_file = $pdf->setSourceFile("gs://bucket2/template.pdf");
for($page_count = 1; $page_count <= $max_pages; $page_count++)
{
//Import the first page of the file
$tppl = $pdf->importPage($page_count);
$pdf->AddPage();
//get size of pdf page
$size = $pdf->getTemplateSize($tppl);
$pdf->useTemplate($tppl, null, null, $size['w'], $size['h'], true);
}
header('Content-Type: application/pdf');
$pdf->Output("template.pdf", "I");
unlink("gs://bucket2/template.pdf");
?>
我通过更新实例 class 和 app.yaml
中的基本缩放解决了这个问题。这只是实验,可能需要根据用例而有所不同,但它确实为我解决了问题。感谢所有在上述评论中提供帮助的人。
application: <APPLICATION NAME>
version: 1
runtime: php55
api_version: 1
instance_class: B2
basic_scaling:
max_instances: 5