私は、消費計画にazureキュー関数を実行しています。私の関数はFFMpegプロセスを開始し、それに応じて非常にCPU集約的です。一度に100個未満のアイテムをキューに入れて実行すると、完全に機能し、空白が拡大し、たくさんのサーバーとすべてのタスクが非常に迅速に完了します。私の問題は、一度に300または400以上のアイテムを一度始めたら、それはうまく始まりますが、しばらくしてCPUは80%の使用率からわずか10%の使用率にゆっくりと移行します。これは、下の画像で見ることができます。 誰かが、私の関数が作成するインスタンスが多くなるほどCPU使用率が低下する理由を知っていますか?事前のおかげでcuaNのffmpeg azure関数の消費計画大量の要求に対してCPU使用率が低い
編集:関数は唯一のインスタンスごとに一つずつ実行に設定されますが、host.json
編集にインスタンスごとに2つのまたは3並行プロセスに設定すると、問題が存在します: CPUの落ち込みは15-20台のサーバーで顕著になり、約60台で障害が発生します。その後、CPUの使用率は平均8〜10%低下し、個人数は0〜3%に達し、サーバー数は制限なしで増加するように見えます私はサーバーといくつかのCPUを持っている場合は、より多くの役立つだろう)
もう一度、クアン。
私はまた、役に立つ場合に備えて、この記事の最後に機能コードを追加しました。
using System.Net;
using System;
using System.Diagnostics;
using System.ComponentModel;
public static void Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed a request: {myQueueItem}");
//Basic Parameters
string ffmpegFile = @"D:\home\site\wwwroot\CommonResources\ffmpeg.exe";
string outputpath = @"D:\home\site\wwwroot\queue-ffmpeg-test\output\";
string reloutputpath = "output/";
string relinputpath = "input/";
string outputfile = "video2.mp4";
string dir = @"D:\home\site\wwwroot\queue-ffmpeg-test\";
//Special Parameters
string videoFile = "1 minute basic.mp4";
string sub = "1 minute sub.ass";
//guid tmp files
// Guid g1=Guid.NewGuid();
// Guid g2=Guid.NewGuid();
// string f1 = g1 + ".mp4";
// string f2 = g2 + ".ass";
string f1 = videoFile;
string f2 = sub;
//guid output - we will now do this at the caller level
string g3 = myQueueItem;
string outputGuid = g3+".mp4";
//get input files
//argument
string tmp = subArg(f1, f2, outputGuid);
//String.Format("-i \"" + @"input/tmp.mp4" + "\" -vf \"ass = '" + sub + "'\" \"" + reloutputpath +outputfile + "\" -y");
log.Info("ffmpeg argument is: "+tmp);
//startprocess parameters
Process process = new Process();
process.StartInfo.FileName = ffmpegFile;
process.StartInfo.Arguments = tmp;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.WorkingDirectory = dir;
//output handler
process.OutputDataReceived += new DataReceivedEventHandler(
(s, e) =>
{
log.Info("O: "+e.Data);
}
);
process.ErrorDataReceived += new DataReceivedEventHandler(
(s, e) =>
{
log.Info("E: "+e.Data);
}
);
//start process
process.Start();
log.Info("process started");
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
}
public static void getFile(string link, string fileName, string dir, string relInputPath){
using (var client = new WebClient()){
client.DownloadFile(link, dir + relInputPath+ fileName);
}
}
public static string subArg(string input1, string input2, string output1){
return String.Format("-i \"" + @"input/" +input1+ "\" -vf \"ass = '" + @"input/"+input2 + "'\" \"" + @"output/" +output1 + "\" -y");
}