From owner-freebsd-questions@FreeBSD.ORG Wed Mar 11 19:47:42 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12A3E246 for ; Wed, 11 Mar 2015 19:47:42 +0000 (UTC) Received: from lb1-smtp-cloud2.xs4all.net (lb1-smtp-cloud2.xs4all.net [194.109.24.21]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client CN "Bizanga Labs SMTP Client Certificate", Issuer "Bizanga Labs CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9BCB218E for ; Wed, 11 Mar 2015 19:47:41 +0000 (UTC) Received: from slackbox.erewhon.home ([83.162.243.5]) by smtp-cloud2.xs4all.net with ESMTP id 2KmU1q00K07iGuj01KmVgf; Wed, 11 Mar 2015 20:46:29 +0100 Received: by slackbox.erewhon.home (Postfix, from userid 1001) id C41691243F; Wed, 11 Mar 2015 20:46:28 +0100 (CET) Date: Wed, 11 Mar 2015 20:46:28 +0100 From: Roland Smith To: opendaddy@hushmail.com Subject: Re: Limiting CPU on some processes on web server Message-ID: <20150311194628.GB8178@slackbox.erewhon.home> Mail-Followup-To: opendaddy@hushmail.com, freebsd-questions@freebsd.org References: <20150311122656.96F2020341@smtp.hushmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0eh6TmSyL6TZE2Uz" Content-Disposition: inline In-Reply-To: <20150311122656.96F2020341@smtp.hushmail.com> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2015 19:47:42 -0000 --0eh6TmSyL6TZE2Uz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 11, 2015 at 12:26:56PM +0000, opendaddy@hushmail.com wrote: > Hi! > > I run this web app that depends on ImageMagick to process images and ffmp= eg > to process videos. These processes, unfortunately, consume 100% of my CPU, > rendering my web app unusable (gateway timeout). *How* does the web app actually start those programs? E.g. if the web app is written in Python, it should use subprocess.Popen() instead of subprocess.call or subprocess.check-output(), because the latter two would block the calling program. As far as I can tell, ImageMagick only uses one core. And whether ffmepg c= an use multiple cores depends on the encoder. X264 can use multiple cores, but Theora can=C2=B4t. So on a relatively modern (multi-core) CPU launching one or two CPU intensi= ve programs should leave enough cores for your web-app. > Tried `nice -n 19` but to no avail. Have you verified with `ps -l` (or `ps -xal`) that the ffmeg and convert processes are actually running at a lower priority? Try using /usr/bin/nice directly instead of using the shell's built-in nice= (assuming the web app starts the commands from a shell?). > What other options do I have? Run you web app stack with a higher priority. Roland --=20 R.F.Smith http://rsmith.home.xs4all.nl/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 5753 3324 1661 B0FE 8D93 FCED 40F6 D5DC A38A 33E0 (keyID: A38A33E0) --0eh6TmSyL6TZE2Uz Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVAJuUAAoJEED21dyjijPgTxAP/0f17q8RUXyDKix61OQu6uKF nwlI0G872mYasgrPdMwGP/YaXD7U3QFN7SXwCF5Ce1ruh4EjZWAdk3S6dLqt7rwv yRhuPXsWlS9QzB6hdtYHEcNw/g41g0o9m/hhvVuKGy9jQC4UgIz8Ymj6IaKTptGX Tv7W7nyE51fvHNibXy6DCd00+73VR4JoD26JRzd6qU90D7mAxdqllEIbdcgViFEX NtT0nPb2pzdcF8/E2KPnb+bpnwMSKbiJh+bFgfdSBlXxL0jw5+0sdR2c3NSWh7e7 VpKvSq9DeI1BgZMs0TKjSFFQPQ1Jjl03Bj1ZD8tMzJQiGWc5Yc/d3nT0sFJHiN/F YC9WjGkMpe4zdXL54Mv8yQGgj03q+ltTikMzzsGHy95quQsVAmnaYBw2361rXjpG uH8rp5BRnUy/qNjZv1Z0RO7yws+BLwe0PnMaITReMl1okGb5okyhYD5kB9Wnk/OY zcjCoLvM2l4jXep1lxs9TSfJ3StOl/I0VOTjORJMO3O7+T4iSjC/10cy6p/dSQhz fM7RtzHMJd8WnWRKvmOLyPAly40HjQ6CrHyaY8wPpV4NyDCmcLfyOAzz/76U84fh hdfjK263ocAwcyLKrUvBbnxgv9hY04Oxdoqm/KF8EtONtkFspURuNI9/oX1PFOuI yl/F+WQno6mZDhUQjAQ5 =eh6J -----END PGP SIGNATURE----- --0eh6TmSyL6TZE2Uz--