Skip to contentSkip to navigationSkip to topbar
On this page

Best Practices for Scaling with Messaging Services


When you're ready to scale messaging for your application, you should keep a few best practices and key questions in mind as you build and work with Twilio.

This guide presents common use cases and location-specific complexities that can affect your messaging application. Knowing how, where, and to whom you plan to send messages will help you avoid some common pitfalls while scaling.


Use a Messaging Service to send messages

use-a-messaging-service-to-send-messages page anchor

Perhaps you built out your messaging application's proof-of-concept by sending messages from a single long code phone number. However, as you scale, your application may require different types of senders, such as short codes, Alpha Sender ID, WhatsApp senders, and phone numbers. You will also want to use features such Advanced Opt-Out(link takes you to an external page) for compliance management, and Smart Encoding to catch those segment-gobbling Unicode symbols.

Intrigued? Check out the full list of Messaging Service features.

You can think of a Messaging Service as a container to hold all of your sender IDs and to manage the configuration affecting the delivery of your messages. For example, you could put your short code and local numbers in one Messaging Service sender pool and configure them to point to the same webhook URL to respond to incoming messages. You could also define the same set of opt-out (Stop) words per country for all of the senders in your sender pool using the Messaging Service Advanced Opt-Out(link takes you to an external page) feature.

When sending messages from a Messaging Service, you can set the From parameter to your Messaging Service SID, instead of a specific phone number. This not only provides intelligent routing for the senders in your Sender Pool, but also gives you access to the various Messaging Service Features, like Advanced Opt-Out, Sticky Sender, Shortcode Reroute, Smart Encoding and more.

Send a Message with a Messaging ServiceLink to code sample: Send a Message with a Messaging Service
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createMessage() {
11
const message = await client.messages.create({
12
body: "Do you know what time it is? It must be party time!",
13
messagingServiceSid: "MG9752274e9e519418a7406176694466fa",
14
to: "+15558675310",
15
});
16
17
console.log(message.body);
18
}
19
20
createMessage();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"api_version": "2010-04-01",
4
"body": "Do you know what time it is? It must be party time!",
5
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
6
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
7
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
8
"direction": "outbound-api",
9
"error_code": null,
10
"error_message": null,
11
"from": "+14155552345",
12
"num_media": "0",
13
"num_segments": "1",
14
"price": null,
15
"price_unit": null,
16
"messaging_service_sid": "MG9752274e9e519418a7406176694466fa",
17
"sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
18
"status": "queued",
19
"subresource_uris": {
20
"media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
21
},
22
"tags": {
23
"campaign_name": "Spring Sale 2022",
24
"message_type": "cart_abandoned"
25
},
26
"to": "+15558675310",
27
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
28
}

Figure out which senders work best for your use case

figure-out-which-senders-work-best-for-your-use-case page anchor
(warning)

Warning

If your messaging use case is Two-Factor Authentication (2FA) codes, you'll want to use Authy or Verify, rather than Programmable Messaging.

Depending on what you build with Twilio Programmable Messaging, you may use different types of message senders as the primary way that customers interact with your application. There are different sender types to choose from:

  • Local and international long code numbers
  • Short code numbers
  • Toll-free numbers
  • Alphanumeric sender IDs
  • WhatsApp senders

The answers to the following questions will determine what kind(s) of senders you should select and include in your Messaging Service's Sender Pool.

1) Are you sending one-way or two-way messages?

1-are-you-sending-one-way-or-two-way-messages page anchor

Consider your use case: do you need your recipients to be able to reply to your messages? If so, that is called "two-way messaging."

More modern messaging channels like WhatsApp always support two-way messaging. With SMS, however, two-way messaging is not always supported; you'll need to make sure that you use the correct number type (if available), or consider an alternative such as WhatsApp.

Check out our two-way SMS FAQ(link takes you to an external page) for more information, or read about WhatsApp(link takes you to an external page).

If you only need to send one-way messages to your recipients, you generally have more options for sender types. However, you still should consider the countries to which you are sending and your use case - read on for details.

2) Where are you sending messages?

2-where-are-you-sending-messages page anchor
(information)

Info

Regulations vary by country, so make sure to check out country-specific guidelines(link takes you to an external page) for the countries in which you plan to send SMS.

Not all sender types work in every country, so you should determine in advance where you want to send messages:

If you're sending in the US and Canada

if-youre-sending-in-the-us-and-canada page anchor

In the United States and Canada, you can send messages from a few types of numbers.

  • US/Canada 10DLC long code phone numbers
  • Short code phone numbers
  • US/Canada Toll-Free numbers
  • WhatsApp-enabled numbers

Please note that Canadian mobile carriers forbid sending application-to-person (A2P) messaging using long code phone numbers, but US Toll-Free numbers can be used for sending A2P traffic on most Canadian carriers. For a comparison of number types for the US and Canada, see here(link takes you to an external page).

If you're sending outside the US and Canada

if-youre-sending-outside-the-us-and-canada page anchor

Outside of the United States and Canada, your possible sender types include:

  • Alphanumeric Sender IDs
  • Long code phone numbers
  • Short code phone numbers
  • Toll-free numbers
  • WhatsApp-enabled numbers

Please note that only US/Canadian Toll-Free numbers can send A2P SMS. When sending messages to non-US countries, carriers treat US Toll-Free numbers just like any other non-local long code phone number.

Consider in-country phone numbers for messaging globally

consider-in-country-phone-numbers-for-messaging-globally page anchor

In some countries, using a local, familiar phone number can improve the read rate of your messages. Using a local number or short code is also required in order to receive incoming replies - see Receiving Two-Way SMS and MMS Messages with Twilio(link takes you to an external page) for details. Depending on your use case and the relevant country regulations, you may want to add in-country numbers to your Messaging Service for each country you want to send SMS to.

3) What kind of content are you sending?

3-what-kind-of-content-are-you-sending page anchor

When selecting senders for your Messaging Service, also consider the flow of content that you'll send to your customers. Message content affects which sender types are available for you to include in your Messaging Service.

There are two main types of messaging to consider:

Common examples of one-way messaging include marketing messages, delivery alerts and other informational messages.

If you plan to send one-way traffic through your application, you will need to choose your sender type based on what is available and permitted by local regulations(link takes you to an external page) for your specific use case in the countries you plan to send messages to. For example, France prohibits the use of local long code numbers for anything except for pure person-to-person (P2P)(link takes you to an external page) conversation traffic, so most organizations will need to use an Alphanumeric Sender ID or a short code to send messages to France.

Depending on availability and per-country regulations, you may use one or more of the following sender types in your Messaging Service's Sender Pool:

  • Short Codes
  • Alphanumeric Sender IDs
  • Non-local long code numbers
  • In-country local long code phone numbers (where permitted by regulations)
  • WhatsApp senders

Common examples of two-way messaging(link takes you to an external page) are chat bots, virtual assistants, and appointment reminders.

For two-way, back-and-forth messaging, you should include one or more of the following in your Messaging Service's Sender Pool:

  • In-country local long code phone numbers
  • Short codes
  • WhatsApp

Determine your messaging throughput needs

determine-your-messaging-throughput-needs page anchor

Message throughput is measured in Messages Segments per Second, but typically abbreviated as MPS. Your throughput needs affects which types and how many senders you should add to your Messaging Service's Sender Pool.

MPS varies by country and by sender type. For US long codes, the MPS you get depends on the outcome of your A2P 10DLC registration(link takes you to an external page). For US Toll-Free, the default MPS is 3, but this can be increased. Outside of the US, it's typically 10 (ten) messages per second. For details, see Understanding Twilio Rate Limits and Message Queues(link takes you to an external page).

MPS Considerations for the US and Canada

mps-considerations-for-the-us-and-canada page anchor

Using multiple long code or Toll-Free numbers to increase your message throughput to the US or Canada is strongly discouraged as it will result in carrier filtering.

For the US, you can get a short code number, which can send messages at 100 MPS or more. Or you can use a single Toll-Free number and talk to Sales about upgrading the number for high-throughput of 25+ MPS.

For Canada, short codes (offering 100+ MPS) and TF are the only permitted ways to send A2P traffic. Using long codes to send A2P messaging traffic will result in increased carrier filtering.

MPS Considerations for the rest of the world

mps-considerations-for-the-rest-of-the-world page anchor

Your options for increasing MPS depend on your traffic type (one-way vs. two-way and A2P vs. P2P, discussed above) and the type of sender(s) you've decided to use.

Alphanumeric Sender ID: by default, Alphanumeric Sender ID offers 10 MPS and its use is country specific. To increase MPS on an Alphanumeric Sender ID, talk to Sales or submit a Support request. Include your expected message volume to the country or countries to which you will send messages.

Long code numbers: by default, long code numbers sending to non-US/Canada countries offer 10 MPS. The MPS on an individual number cannot be increased, but you can add more numbers.

Twilio has built a highly available, distributed queue, so you don't have to worry about these limits. Your application can send Twilio's Programmable Messaging API requests as quickly as you'd like. We'll queue your messages for you and send them out at the appropriate rate for your senders. This keeps your application in compliance, but this can delay the delivery of your messages.

To find out more details, read this article about Twilio Rate Limits and Message Queues(link takes you to an external page).


Use a short code or toll-free number for higher throughput

use-a-short-code-or-toll-free-number-for-higher-throughput page anchor
(warning)

Warning

We caution against adding more long code phone numbers to your Messaging Service's Sender Pool to distribute the load, a practice known as "snowshoeing." Instead, consider upgrading to a sender type with higher throughput, such as a toll-free number or short code(link takes you to an external page), if available in your area.

If you're sending to a country where Twilio offers short code numbers: As of Q4 2022, Twilio offers short code numbers(link takes you to an external page) in 14 countries, including the US, Canada, UK, Mexico, and Brazil. Apply for a short code to take advantage of a higher throughput rate, typically starting at 100 messages per second, and robust delivery. Short codes have the advantage of carrier pre-approval; this means that your use case has been reviewed by carriers, greatly reducing filtering risk.

Short codes can only be used to send domestic traffic (e.g., Canadian short codes can only send SMS in Canada.). In addition to using short codes, you should add other numbers or Alpha Sender ID if you plan to send SMS to countries where short codes are not offered, or where a short code does not make sense for your expected message volume.

Please note that in the US and Canada, some smaller mobile carriers may not support short code messages(link takes you to an external page). To achieve the highest levels of deliverability, you should add a few long codes to your messaging service. In the US and Canada, the Short Code Reroute feature will send from a long code phone number when a short code is not supported.

If you're sending to a country where Twilio does not offer short code numbers: Consult the SMS Guidelines(link takes you to an external page) for the country in question, and add appropriate numbers to your Messaging Service depending on your use case. For example, for 1-way messaging to many countries in the world, you can add US/Canada numbers to your Messaging Service, or enable Alphanumeric Sender ID.


Alphanumeric Sender IDs and Throughput

alphanumeric-sender-ids-and-throughput page anchor

If you are using an alphanumeric sender ID, it will take precedence over the other phone numbers in your Messaging Service sender pool, even if it has queued messages. Message delivery does not fall back from alphanumeric sender IDs to the long code phone numbers in your sender pool.

If you are planning to use an alphanumeric sender ID in a supported country, make sure that you get the right MPS rate for it. You can request higher throughput on your alphanumeric sender ID through Support.


When you're ready to scale with Twilio Programmable Messaging, we highly recommend moving your application to a Messaging Service, if you have not already done so. That way, you'll have access to all of the built-in features that help you send messages globally and at high-volume, all while managing a single sender pool.

The fastest way to scale your messaging application is to identify your use case and messaging needs from the start. Knowing where you'll be sending messages, what type of content you'll send to customers, and how quickly you need those messages to be sent will point you to the right sender types to include in your Messaging Service.

Also check out:

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.