Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed fern/images/34619bc-alch_security.png
Binary file not shown.
Binary file removed fern/images/3bf4e5e-nim_dash.png
Binary file not shown.
Binary file added fern/images/restrict-access.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fern/images/security.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
---
title: Best Practices When Using Alchemy
description: Here is a list of best practices to reduce compute unit usage costs to make sure you’re getting the most out of Alchemy’s platform! We will continue updating these as we receive customer feedback. 1. Send Requests Concurrently Depending on your background with blockchain nodes, you might expect that...
subtitle: Here is a list of best practices to reduce compute unit usage costs to make sure you’re getting the most out of Alchemy’s platform! We will continue updating these as we receive customer feedback. 1. Send Requests Concurrently Depending on your background with blockchain nodes, you might expect that...
slug: docs/best-practices-when-using-alchemy
---

Here is a list of best practices to reduce [compute unit usage costs](/reference/compute-units) to make sure you’re getting the most out of Alchemy’s platform!

We will continue updating these as we receive customer feedback.

## 1. Send Requests Concurrently

Depending on your background with blockchain nodes, you might expect that requests need to be sent sequentially to function properly. That’s not the case!
Expand Down Expand Up @@ -43,7 +39,7 @@ Implementing exponential backoff retry logic in your application will help handl

## 4. Send Requests over HTTPS, not WebSockets

Though it may be tempting to use WebSockets for all node requests because it’s a newer technology, the [industry best practice for using WebSockets](/docs/best-practices-for-using-websockets-in-web3) is still primarily for push-based notifications. In the case of EVM chains, `eth_subscribe` and `eth_unsubscribe` to certain events.
Though it may be tempting to use WebSockets for all node requests because it’s a newer technology, the [industry best practice for using WebSockets](/docs/reference/best-practices-for-using-websockets-in-web3) is still primarily for push-based notifications. In the case of EVM chains, `eth_subscribe` and `eth_unsubscribe` to certain events.

HTTPS is a better option for standard JSON-RPC node requests for several reasons:

Expand All @@ -55,31 +51,25 @@ HTTPS is a better option for standard JSON-RPC node requests for several reasons

* **HTTP status codes**: When web3 developers use WebSockets they won't receive HTTP status codes in WebSockets responses, which can be useful for debugging or sorting responses.

## 4. Avoid Large Request / Response Sizes
## 5. Avoid Large Request / Response Sizes

We recommend keeping the vast majority of requests to be under 100 KB and avoiding response sizes above 10 MB.

Though we permit sending large requests (currently up to 2.5 MB) and receiving large responses (currently up to 150 MB), we strongly suggest avoiding these limits as much as possible. This is for several reasons: Larger requests and responses are more likely to hit our size limits, which will result in failing API calls that you’ll have to retry. Heavy API calls have higher likelihood of timing out, failing while in flight, and causing nodes to become unstable. Smaller API calls are easier to debug and identify issues that arise.

By keeping your API calls an order of magnitude smaller than our hard limits, your infrastructure will become more reliable, responsive, and you’ll spend less time debugging your dApp.

## 5. Use gZip Compression to Speed Up Large Requests
## 6. Use gZip Compression to Speed Up Large Requests

At Alchemy, many of our developers have brought up slow response times as a major blocker to providing their customers with a good web3 user experience.

To provide users with better product experiences, we updated our internal infrastructure to offer Alchemy developers **support for gzip compression on all responses larger than 1kb in size.**

In practice, we’ve seen roughly a **75% improvement in the total latency of typical JSON-RPC replayTransaction calls.**

Go to the article below to learn how to implement gZip compression:

[![How to Enable Compression to Speed Up JSON-RPC Blockchain Requests](https%3A%2F%2F3169887760-files.gitbook.io%2F~%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MB17w56kk7ZnRMWdqOL%252Fsocialpreview%252FtgxWJf2xDuUaJyGF7gaS%252Falchemy-logo.png%3Falt%3Dmedia%26token%3D58b4377f-b9fa-4fdb-ad28-a43620781c90)](/docs/alchemy/guides/how-to-enable-compression-to-speed-up-json-rpc-blockchain-requests)

[![docs.alchemy.com](spaces%2F-MB17w56kk7ZnRMWdqOL%2Favatar-1631043648701.png)docs.alchemy.com](/docs/alchemy/guides/how-to-enable-compression-to-speed-up-json-rpc-blockchain-requests)
Go to this article to learn how to implement gZip compression: [How to Enable Compression to Speed Up JSON-RPC Blockchain Requests](/docs/alchemy/guides/how-to-enable-compression-to-speed-up-json-rpc-blockchain-requests)

[How to Enable Compression to Speed Up JSON-RPC Blockchain Requests](/docs/alchemy/guides/how-to-enable-compression-to-speed-up-json-rpc-blockchain-requests)

## 6. Contact Us When Multiplying Your Capacity
## 7. Contact Us When Multiplying Your Capacity

Are you planning on launching the next big NFT project? Planning a major indexing project to backfill your databases with custom node data?

Expand All @@ -101,21 +91,17 @@ At Alchemy, we’ve solved most of these issues, but the more advanced warning y

For large projects, we provide white-glove support and direct access to our engineers; one of the reasons our customers love us so much. We’re available and willing to help with your infrastructure needs - just let us know!

## 7. Protecting your API Keys
## 8. Protecting your API Keys

There might be instances where you want to embed your API key somewhere public, like frontend-only applications. To avoid unintended use of the API Key, you can setup an allowlist within your Alchemy dashboard, specifying what domains, contract addresses, wallet addresses, or IP addresses are able to send requests.

To do this, visit your unique app page in the dashboard, and click on "Security" in the top right.

![1280](34619bc-alch_security.png "alch_security.png")

Security Button

This will open up a pop-up screen that allows you to restrict access to your API key
![1280](security.png "security.png")

![1424](3bf4e5e-nim_dash.png "nim_dash.png")
This will bring you to a page that allows you to restrict access to your API key

Restrict app access
![1424](restrict-access.png "restrict-access.png")

Learn more about it [here](/docs/how-to-add-allowlists-to-your-apps-for-enhanced-security).

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading