forked from awslabs/aws-support-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added OW sample-cookbooks director, and cpulimit-ruby example cookbook for managing CPU utilization of Ruby processes.
- Loading branch information
Nick Alteen
committed
Jun 21, 2017
1 parent
8310784
commit 880bcaa
Showing
28 changed files
with
249 additions
and
358 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
# Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" | ||
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under the License. | ||
|
||
# cpulimit-ruby | ||
|
||
TODO: Enter the cookbook description here. | ||
In the case of CPU-critical workloads running on OpsWorks Stacks instances, the CPU consumption by Ruby processes during lifecycle events can affect the performance of applications running on instances. In stacks with many layers and instances, it is possible for a large series of Configure events to consume CPU resources for an extended period of time. | ||
|
||
As this is a built in component of how Chef runs are performed; there is little that can be done by OpsWorks to limit the amount of CPU consumed by Ruby. However, we do have the ability to monitor and limit this on instances using a custom cookbook. | ||
|
||
Specifically, we make use of a tool to control the CPU amount using SIGSTOP and SIGCONT POSIX signals. The benefit to using this tool is that child processes and threads are affected by this limit as well. | ||
|
||
If you would like to instead configure this as a service to run on instances, continually checking for Ruby processes to limit, the attached cookbook will perform the following configuration tasks: | ||
|
||
- Create the /opt/cpulimit directory to store any needed files. | ||
- Create a file, /opt/cpulimit/cpulimit.sh, which acts in a similar manner to the script above, continuously checking for the existence of Ruby processes on the instance. | ||
- Create a file, /etc/init.d/cpulimit, which registers cpulimit as a service on the instance. | ||
- Starts and enables the new cpulimit service. | ||
|
||
Once this is started on instances, any Ruby processes caught by the script cpulimit.sh will be throttled to less than 20% CPU for their duration. The percentage to throttle can be configured by adjusting the attribute default['cpulimit']['cpu-limit'], which can be found in attributes.rb in the provided cookbook. |
12 changes: 12 additions & 0 deletions
12
OpsWorks/sample-cookbooks/cpulimit-ruby/attributes/default.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
# Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" | ||
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under the License. | ||
|
||
|
||
# Controls the integer percentage set as the | ||
# maximum CPU for Ruby. | ||
default['cpulimit']['cpu-limit'] = "20" |
16 changes: 0 additions & 16 deletions
16
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/LICENSE
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/README.md
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 10 additions & 26 deletions
36
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/cpulimit.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/list.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/list.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 11 additions & 14 deletions
25
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/memrchr.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
/* | ||
* Copyright (c) 2007 Todd C. Miller <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
/** | ||
# Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | ||
# except in compliance with the License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed on an "AS IS" | ||
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
#include <sys/types.h> | ||
|
28 changes: 10 additions & 18 deletions
28
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/process_group.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/process_group.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
OpsWorks/sample-cookbooks/cpulimit-ruby/files/default/cpulimit-master/src/process_iterator.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.