# US 2021/0240509 A1 · Single use execution environment for on-demand code execution

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0240509 A1
- Document ID: US20210240509A1
- Status: Published application
- Kind: A1
- Application number: 16/782,873
- Filed: 2020-02-05
- Published: 2021-08-05
- Earliest claimed: 2020-02-05
- Assignees: Amazon Technologies, Inc.
- Applicants: Amazon Technologies, Inc.
- Inventors: Marc Brooker; Mikhail Danilov; Osman Surkatty; Tao Chen
- Web page: https://patentgrep.com/patent/US20210240509A1

## CPC

- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 21/53: by executing in a restricted environment, e.g. sandbox or secure virtual machine
- G06F 12/0882: Page mode
- G06F 12/0891: using clearing, invalidating or resetting means
- G06F 12/0804: with main memory updating (G06F12/0806 takes precedence)
- G06F 12/0897: with two or more cache hierarchy levels (with multilevel cache hierarchies G06F12/0811)
- G06F 2009/45562: {Creating, deleting, cloning virtual machine instances}
- G06F 2009/4557: {Distribution of virtual machine instances; Migration and load balancing}
- G06F 2009/45575: {Starting, stopping, suspending or resuming virtual machine instances}
- G06F 2009/45583: {Memory management, e.g. access or allocation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods are provided for efficiently configuring an execution environment for an on-demand code execution system to handle a single request (or session) for a single user. Once the session or request is complete, the execution environment is reset, such as by having the hardware processor state, memory, and storage reset. In particular, prior to the execution of code, state of the execution environment of the host computing device is retrieved, such as hardware processor(s), memory, and/or storage state. Moreover, during execution of the code instructions, intermediate state can be gathered. Following the execution of the code, the execution environment is reset based on the saved state related to the hardware processor(s), memory, and/or storage. A subsequent code execution securely occurs in the execution environment and the execution environment is reset again, and so forth.

## Claims

### Claim 1

A computer implemented method comprising:
under control of a computer hardware processor configured with specific computer executable instructions,
receiving, from a host computing device in an on-demand code execution system, first hardware processor state from a hardware processor of the host computing device;
receiving, from the host computing device, first storage device state from a storage device of the host computing device;
causing code instructions to execute in an execution environment on a virtual machine instance of the host computing device;
while causing the code instructions to execute in the execution environment on the virtual machine instance of the host computing device,
receiving, from the host computing device, memory device state from a memory device of the host computing device, wherein causing the code instructions to execute causes:
the hardware processor of the host computing device to change to a second hardware processor state,
the storage device of the host computing device to change to a second storage device state, and
the memory device of the host computing device to change in state; and
resetting the execution environment on the virtual machine instance of the host computing device, wherein resetting the execution environment further comprises:
transmitting reset instructions to the hardware processor of the host computing device, wherein the reset instructions are configured to cause the hardware processor of the host computing device to revert to the first hardware processor state;
causing the storage device of the host computing device to revert back to the first storage device state; and
causing the memory device of the host computing device to revert to an initial state based at least in part on the memory device state.

### Claim 2 (depends on 1)

The computer implemented method of claim 1, wherein causing the code instructions to execute causes:
recording, in the host computing device, the memory device state that indicates a memory page that was accessed or modified.

### Claim 3 (depends on 2)

The computer implemented method of claim 2, wherein recording the memory device state that indicates the memory page that was accessed further comprises:
generating a duplicate memory page of the memory page that was accessed.

### Claim 4 (depends on 3)

The computer implemented method of claim 3, wherein causing the memory device of the host computing device to revert to the initial state based at least in part on the memory device state further comprises discarding the duplicate memory page.

### Claim 5 (depends on 2)

The computer implemented method of claim 2, wherein recording the memory device state that indicates the memory page that was accessed further comprises:
generating a duplicate memory page of the memory page that was modified.

### Claim 6 (depends on 1)

The computer implemented method of claim 1, wherein the reset instructions are further configured to flush a cache of the hardware processor.

### Claim 7

A system comprising:
a data storage medium; and
one or more computer hardware processors in communication with the data storage medium, the one or more computer hardware processors configured to execute computer-executable instructions to at least:
receive, from a host computing device in an on-demand code execution system, first hardware processor state from a hardware processor of the host computing device;
cause first code instructions to execute in an execution environment on a virtual machine instance of the host computing device;
while causing the first code instructions to execute in the execution environment on the virtual machine instance of the host computing device, the one or more computer hardware processors is further configured to:
receive, from the host computing device, memory device state from a memory device of the host computing device, wherein to cause the first code instructions to execute causes:
the hardware processor of the host computing device to change to a second hardware processor state, and
the memory device of the host computing device to change in state; and
reset the execution environment on the virtual machine instance of the host computing device, wherein to reset the execution environment, the one or more computer hardware processors is further configured to:
transmit reset instructions to the hardware processor of the host computing device, wherein the reset instructions are configured to cause the hardware processor of the host computing device to revert to the first hardware processor state; and
cause the memory device of the host computing device to revert to an initial state based at least in part on the memory device state.

### Claim 8 (depends on 7)

The system of claim 7, wherein to cause the first code instructions to execute, the host computing device is further configured to:
create a bit map that indicates at least a first clean memory page and a second memory page that has been accessed or modified, wherein the memory device state indicates that the second memory page has been accessed or modified.

### Claim 9 (depends on 8)

The system of claim 8, wherein to cause the memory device of the host computing device to revert to the initial state based at least in part on the memory device state, the one or more computer hardware processors is further configured to:
identify, using the bit map, the first clean memory page and the second memory page that has been accessed or modified;
maintain the first clean memory page; and
replace the second memory page that has been accessed or modified with a clean second memory page.

### Claim 10 (depends on 7)

The system of claim 7, wherein the host computing device further comprises a reset device, wherein the reset device comprises a processor of the one or more computer hardware processors configured to transmit the reset instructions to the hardware processor of the host computing device.

### Claim 11 (depends on 7)

The system of claim 7, wherein to cause the memory device of the host computing device to revert to the initial state, at least a portion of the memory device is instructed to power off and power on.

### Claim 12 (depends on 7)

The system of claim 7, wherein the first code instructions are received from a first user computing device, and wherein the one or more computer hardware processors is further configured to:
receive, from a second user computing device different from the first user computing device, second code instructions; and
cause the second code instructions to execute in the execution environment on the virtual machine instance of the host computing device.

### Claim 13

A system comprising:
a data storage medium; and
one or more computer hardware processors in communication with the data storage medium, the one or more computer hardware processors configured to execute computer-executable instructions to at least:
receive, from a first host computing device in an on-demand code execution system, first hardware processor state from a hardware processor of the host computing device;
while first code instructions execute in a first execution environment on a first virtual machine instance of the first host computing device,
receive, from the first host computing device, memory device state from a memory device of the first host computing device, wherein to cause the first code instructions to execute causes:
the hardware processor of the first host computing device to change to a second hardware processor state, and
the memory device of the first host computing device to change in state; and
reset the first execution environment on the first virtual machine instance of the first host computing device, wherein to reset the first execution environment, the one or more computer hardware processors is further configured to:
transmit reset instructions to the hardware processor of the first host computing device, wherein the reset instructions are configured to cause the hardware processor of the first host computing device to revert to the first hardware processor state; and
cause the memory device of the first host computing device to revert to an initial state based at least in part on the memory device state.

### Claim 14 (depends on 13)

The system of claim 13, wherein the one or more computer hardware processors is further configured to:
while first code instructions execute in the first execution environment on the first virtual machine instance of the first host computing device,
pause execution of the first code instructions in the first execution environment on the first virtual machine instance of the first host computing device;
receive, from the first host computing device, the second hardware processor state;
transmit, to a second host computing device, the second hardware processor state and the memory device state;
cause a second execution environment on a second virtual machine instance of the second host computing device to initialize according to the second hardware processor state and the memory device state; and
resume execution of the first code instructions in the second execution environment on the second virtual machine instance of the second host computing device.

### Claim 15 (depends on 14)

The system of claim 14, wherein the one or more computer hardware processors is further configured to:
determine that there is a performance issue associated with the execution of the first code instructions on the first host computing device.

### Claim 16 (depends on 13)

The system of claim 13, wherein the one or more computer hardware processors is further configured to:
gather first performance data regarding execution of the first code instructions on the first host computing device;
cause a second execution of the first code instructions in a second execution environment on a second virtual machine instance of a second host computing device; and
gather second performance data regarding execution of the first code instructions on the first host computing device.

### Claim 17 (depends on 16)

The system of claim 16, wherein the one or more computer hardware processors is further configured to:
determine that, relative to the first performance data, the second performance data has a higher performance metric; and
cancel execution of the first code instructions on the first host computing device.

### Claim 18 (depends on 13)

The system of claim 13, wherein the first host computing device comprises a storage device, the storage device comprising a trusted storage sector, wherein the one or more computer hardware processors is further configured to:
while first code instructions execute in the first execution environment on the first virtual machine instance of the first host computing device,
receive, from the first host computing device, first storage device state that indicates that first data was stored on the trusted storage sector,
wherein to reset the first execution environment, the one or more computer hardware processors is further configured to:
maintain the first data in the trusted storage sector.

### Claim 19 (depends on 18)

The system of claim 18, wherein the one or more computer hardware processors is further configured to:
cause second code instructions to execute in the first execution environment on the first virtual machine instance of the first host computing device; and
while second code instructions execute in the first execution environment on the first virtual machine instance of the first host computing device,
receive, from the first host computing device, second storage device state that indicates that the first data was accessed on the trusted storage sector.

### Claim 20 (depends on 13)

The system of claim 13, wherein the one or more computer hardware processors is further configured to:
initialize a base execution environment on the first virtual machine instance of the first host computing device; and
insert customized data for the first code instructions into the base execution environment to result in the first execution environment, wherein execution of the first code instructions in the first execution environment accesses the customized data.
