In this blog post, we explain Zstandard (ZSTD), a fast data compression algorithm that offers best-in-kind performance, in a way that is super simple to understand. If you’re interested in learning by watching or listening, check out a video about this open source project on our Facebook Open Source YouTube channel.
Zstandard (ZSTD) is a fast, lossless compression algorithm. It provides high compression ratios as well as great compression and decompression speeds, offering best-in-kind performance in many conventional situations. In addition to this, ZSTD now has a number of features that make a lot of real-world scenarios that have previously been difficult to achieve for compressors, possible.
There are three standard metrics for comparing compression algorithms and implementations:
- Compression ratio: A ratio between the original size and the compressed size.
- Compression speed: How quickly the data can be made smaller, measured in MB/s.
- Decompression speed: How quickly the original data can be reconstructed from the compressed data, measured in MB/s.
Many of the algorithms commonly used today focus on one of the metrics from above or try to strike a balance between them. Several fast compression algorithms were tested and compared and as shown in the figure below, there are often drastic compromises between speed and size (source).
The fastest algorithm, Iz4 1.9.2, results in lower compression ratios; the one with the highest compression ratio (other than ZSTD), zlib 1.2.11-1, suffers from a slow compression speed. However, ZSTD shows substantial improvements in both compression speed and decompression speed, while maintaining a high compression ratio. Note that the negative compression levels, specified with –fast=X, offer faster compression and decompression speeds in exchange for some loss in compression ratio compared to level 1.
As shown in the chart below, ZSTD offers a very wide range of speed/compression trade-offs, which lets ZSTD trade compression speeds for better compression ratios and vice versa. ZSTD can provide these speeds because it is backed by an extremely fast decoder (source).
However, most of these results apply to typical file and stream scenarios, which are typically several MBs in size. Data smaller than this is handled in a slightly different manner.
Generally speaking, the smaller the amount of data to compress, the more difficult it is to compress. Compression algorithms learn from past data how to compress future data. At the beginning of a new data set, there is no past data to build upon, making it more challenging. To solve this problem, ZSTD offers a special training mode, which can be used to tune the algorithm for a selected type of data. A dictionary is generated from the results obtained from this training and helps capture common patterns in the data. This dictionary must be loaded before the compression and decompression. Once the patterns have been captured, the dictionary assumes future data will be similar and begins the compression. By using this dictionary, the compression ratio on small data improves drastically as shown in the graph below (source).
The type of data being compressed can also affect these metrics. Many algorithms are tuned for specific types of data, such as English text, genetic sequences, or rasterized images; however, ZSTD is meant for general-purpose compression for a variety of data types.
Where is ZSTD used?
ZSTD was open-sourced in 2016 and is used continuously to compress large amounts of data in multiple formats in Facebook’s development servers, data warehouse, databases and compressed file systems as a powerful and flexible compressor engine. To get a better understanding of where ZSTD is used check out this Facebook Engineering blog that explains how Facebook improved compression at scale with ZSTD.
ZSTD is used by Linux, FreeBSD, Amazon Web Services, and many more. For a detailed list of industries where ZSTD is being used, check out their website.
Where can I learn more?
ZSTD has a rich collection of APIs and supports a number of popular programming languages. To learn more about ZSTD, visit their website, which contains great information on the benchmarks and the various languages that are supported. If you’d like to learn about how to use this algorithm, build instructions and testing, make sure to visit the project’s Github page. For detailed API reference, check out its documentation.
If you have any further questions about ZSTD, please let us know on our YouTube channel, or by tweeting at us. We always want to hear from you and hope you will find this open source project and the ELI5 series useful.
About the ELI5 series
In a series of short videos, one of our Developer Advocates on the Facebook Open Source team explains a Facebook open source project in a way that is easy to understand and use.
We will write an accompanying blog post (like the one you’re reading right now) for each of these videos, which you can find on our YouTube channel.
Interested in working with open source at Facebook? Check out our open source-related job postings on our career page by taking this quick survey.
Now people can share directly to Instagram Reels from some of their favorite apps
More people are creating, sharing and watching Reels than ever before. We’ve seen the creator community dive deeply into video content – and use it to connect with their communities. We’re running a limited alpha test that lets creators share video content directly from select integrated apps to Instagram Reels. Now, creators won’t be interrupted in their workflow, making it easier for them share share and express themselves on Reels.
“With the shift to video happening across almost all online platforms, our innovative tools and services empower creativity and fuel the creator economy and we are proud to be able to offer a powerful editing tool like Videoleap that allows seamless content creation, while partnering with companies like Meta to make sharing content that much easier.”- Zeev Farbman, CEO and co-founder of Lightricks.
Starting this month, creators can share short videos directly to Instagram Reels from some of their favorite apps, including Videoleap, Reface, Smule, VivaVideo, SNOW, B612, VITA and Zoomerang, with more coming soon. These apps and others also allow direct sharing to Facebook , which is available for any business with a registered Facebook App to use.
We hope to expand this test to more partners in 2023. If you’re interested in being a part of that beta program, please fill out this form and we will keep track of your submission. We do not currently have information to share about general availability of this integration.
Learn more here about sharing Stories and Reels to Facebook and Instagram and start building today.
Q. What is the difference between the Instagram Content Publishing API and Instagram Sharing to Reels?
A: Sharing to Reels is different from the Instagram Content Publishing API, which allows Instagram Business accounts to schedule and publish posts to Instagram from third-party platforms. Sharing to Reels is specifically for mobile apps to display a ‘Share to Reels’ widget. The target audience for the Share to Reels widget is consumers, whereas the Content Publishing API is targeted towards businesses, including third-party publishing platforms such as Hootsuite and Sprout Social that consolidate sharing to social media platforms within their third-party app.
Q: Why is Instagram partnering with other apps?
A: Creators already use a variety of apps to create and edit videos before uploading them to Instagram Reels – now we’re making that experience faster and easier. We are currently doing a small test of an integration with mobile apps that creators know and love, with more coming soon.
Q: How can I share my video from another app to Reels on Instagram?
A: How it works (Make sure to update the mobile app you’re using to see the new Share to Reels option):
- Create and edit your video in one of our partner apps
- Once your video is ready, tap share and then tap the Instagram Reels icon
- You will enter the Instagram Camera, where you can customize your reel with audio, effects, Voiceover and stickers. Record any additional clips or swipe up to add an additional clip from your camera roll.
- Tap ‘Next’ to add a caption, hashtag, location, tag others or use the paid partnerships label.
- Tap ‘Share’. Your reel will be visible where you share reels today, depending on your privacy settings.
Q: How were partners selected?
A. We are currently working with a small group of developers that focus on video creation and editing as early partners. We’ll continue to expand to apps with other types of creation experiences.
Q: When will other developers be able to access Sharing to Reels on Instagram?
A: We do not currently have a date for general availability, but are planning to expand further in 2023.
Q: Can you share to Facebook Reels from other apps?
A: Yes, Facebook offers the ability for developers to integrate with Sharing to Reels. For more information on third-party sharing opportunities, check out our entire suite of sharing offerings .
First seen at developers.facebook.com
What to know about Presto SQL query engine and PrestoCon
The open source Presto SQL query engine is used by a diverse set of companies to navigate increasingly large data workflows. These companies are using Presto in support of e-commerce, cloud, security and other areas. Not only do many companies use Presto, but individuals from those companies are also active contributors to the Presto open source community.
In support of that community, Presto holds meetups around the world and has an annual conference, PrestoCon, where experts and contributors gather to exchange knowledge. This year’s PrestoCon, hosted by the Linux Foundation, takes place December 7-8 in Mountain View, CA. This blog post will explore some foundational elements of Presto and what to expect at this year’s PrestoCon.
What is Presto?
Presto is a distributed SQL query engine for data platform teams. Presto users can perform interactive queries on data where it lives using ANSI SQL across federated and diverse sources. Query engines allow data scientists and analysts to focus on building dashboards and utilizing BI tools so that data engineers can focus on storage and management, all while communicating through a unified connection layer.
In short, the scientist does not have to consider how or where data is stored, and the engineer does not have to optimize for every use case for the data sources they manage. You can learn more about Presto in a recent ELI5 video below.
Caption: Watch the video by clicking on the image above.
Presto was developed to solve the problem of petabyte-scale, multi-source data queries taking hours or days to return. These resources and time constraints make real-time analysis impossible. Presto can return results from those same queries in less than a second in most cases, allowing for interactive data exploration.
Not only is it highly scalable, but it’s also extensible, allowing you to build your own connector for any data source Presto does not already support. At a low level, Presto also supports a wide range of file types for query processing. Presto was open sourced by Meta and later donated to the Linux Foundation in September of 2019.
Here are some Presto resources for those who are new to the community:
What is PrestoCon?
PrestoCon is held annually in the Bay Area and hosted by the Linux Foundation. This year, the event takes place December 7-8 at the Computer History Museum. You can register here. Each year at PrestoCon, you can hear about the latest major evolutions of the platform, how different organizations use Presto and what plans the Technical Steering Committee has for Presto in the coming year.
Presto’s scalability is especially apparent as every year we hear from small startups, as well as industry leaders like Meta and Uber, who are using the Presto platform for different use cases, whether those are small or large. If you’re looking to contribute to open source, PrestoCon is a great opportunity for networking as well as hearing the vision that the Technical Steering Committee has for the project in the coming year.
Explore what’s happening at PrestoCon 2022:
Where is Presto used?
Since its release in November of 2013, Presto has been used as an integral part of big data pipelines within Meta and other massive-scale companies, including Uber and Twitter.
The most common use case is connecting business intelligence tools to vast data sets within an organization. This enables crucial questions to be answered faster and data-driven decision-making can be more efficient.
How does Presto work?
First, a coordinator takes your statement and parses it into a query. The internal planner generates an optimized plan as a series of stages, which are further separated into tasks. Tasks are then assigned to workers to process in parallel.
Workers then use the relevant connector to pull data from the source.
The output of each task is returned by the workers, until the stage is complete. The stage’s output is returned by the final worker towards the next stage, where another series of tasks must be executed.
The results of stages are combined, eventually returning the final result of the original statement to the coordinator, which then returns to the client.
How do I get involved?
We would love for you to join the Presto Slack channel if you have any questions or need help. Visit the community page on the Presto website to see all the ways you can get involved and find other users and developers interested in Presto.
Where can I learn more?
To learn more about Presto, check out its website for installation guides, user guides, conference talks and samples.
First seen at developers.facebook.com
How to Interpret Webhook Components in the WhatsApp Business Platform
The ways customers want to connect are changing. The WhatsApp Business Platform gives businesses an integrated way to communicate with customers right where they are. In order to integrate properly when using the Cloud API, hosted by Meta, you’ll need to leverage webhooks so applications have a way to respond to events. Webhooks allow your application to monitor three primary events on WhatsApp so you can react with different functionality depending on your goals.
This article looks at these three components, goes through the information they carry, and provides some use-case scenarios to give you an idea of the possibilities.
Interpreting Different Webhook Components
To send and receive messages on WhatsApp, it’s critical to keep track of statuses and errors to help ensure you’re communicating effectively with your customers, which you can do with webhooks.
With webhooks, the WhatsApp Business Platform monitors events and sends notifications when one occurs. These events are one of three components: messages, statuses, and errors.
Let’s explore each of these and examine examples of how you can use them.
The messages component is the largest of the three event types and contains two core objects:
Contacts — which contain information about the message’s sender.
Messages — which provide information about a message’s type and contents.
These two event types allow your application to manage and respond to people that interact with your application. The contacts object contains two pieces of information: name and WhatsApp Id. The contact’s name allows your application to use their name without further lookups. In contrast, the contact’s WhatsApp ID lets you keep track of these contacts or use the contacts/ endpoint to add additional functionality.
For instance, you can verify the customer and start the opt-in process within the customer-initiated conversation, which allows you to message them outside the initial 24-hour response window. It’s important to note that only the text, contacts, and location message types provide contact information.
The message object is where the bulk of the information is stored, including the message contents, type of message, and other relevant information. Depending on the message type, the actual payload of the message component can vary widely. It’s crucial to determine the message type to understand the potential payload. Message types include:
Text: a standard text-only message
Contact: contains a user’s full contact details
Location: address, latitude, and longitude
Unknown: unsupported messages from users, which usually contain errors.
Ephemeral: disappearing messages
Media message types: contain information for the specified media file. These types include:
These different data types can have very different uses, from reviewing images and screenshots from concerned customers to collecting information about where to ship goods and send services. To use these different data types most effectively, you can create applications to handle different forms of communication, with functionalities such as:
Ask your customers to provide a shipping or mailing address. You can use the location-based message feature to capture your users’ location to determine where to send their goods and services.
Show customers products and communicate product details through a message. You can use the referred_product field within messages to offer your users specific product details. Using this field develops a more personal, conversational shopping experience and customer interactions.
Build support functionality that allows customers to take and send images and videos of product concerns, and submit those for a support case. Once the user has submitted a support ticket, the app can track the case — including steps taken towards resolution and conversations between support teams and the customer through WhatsApp — using a unique case identifier.
These are just some potential features you can build using the interactivity provided by webhooks and the message object. These features extend your current communication channels and provide additional options for customers.
Where the messages component provides your application with insight into events that originate directly from your customers, the statuses component keeps track of the results of messages you send and the conversation history. There are six status components:
- Sent: the application sent your message and is in transit.
- Delivered: the user’s device successfully received the message.
- Read: the user has read your message.
- Deleted: a user deleted a message that you sent.
- Warning: a message sent by your application contains an item that isn’t available or doesn’t exist.
- Failed: a message sent by your application failed to arrive.
Status components also contain information on the recipient ID, the conversation, and the pricing related to the current conversation. Conversations on WhatsApp are a grouping of messages within a 24-hour window that are either user-initiated or business-initiated. Keeping track of these conversations is vital, as a new conversation occurs when you send additional responses after the 24-hour period ends.
Some functionality you may want to add to your application based on status events includes:
- Ensuring your application has sent generated messages, they arrived, and the recipient potentially read them by using a combination of these status types and timestamps within the status object. This information allows your application to follow up with customers if they didn’t engage.
- Keep analytical information about your application’s messages, especially regarding business-initiated conversations. For example, if your application uses a WhatsApp customer contact list to send offer messages, the status component helps you understand how many were sent, delivered, read, responded to, or failed to measure your campaign’s success.
Finally, the errors component allows your application to receive any out-of-band errors within WhatsApp that affect your platform. These errors don’t stop your application from compiling or working but are typically caused when your application is misusing specific functionality. The following are some typical errors.
Error Code 368, Temporarily Blocked for Policy Violations
If your application violates WhatsApp Business Messaging or Commerce policy, your account may be temporarily banned. You can monitor this and pause your application while troubleshooting.
Error 506, Duplicate Post
If your workflows unintentionally generate duplicate messages, you can monitor this to find the source.
Error 131043, Message Expired
Sometimes, messages are not sent during their time to live (TTL) duration. Use this code to know which messages to schedule for resending if needed.
Error handling is a broad, complex subject, and there are many other use cases for which you should be implementing error handling. The errors component helps extend your error handling on the WhatsApp Business Platform for greater consistency.
This article took a high-level look at messages, statuses, and errors returned by webhooks and explored ways you can use these three components to expand your application’s functionality.
Messages provide information on customer interactions, statuses give insight into messages your app sends, and error notices enable you to increase your application’s resilience. Webhooks are critical to ensuring your app interacts with customers seamlessly.
The WhatsApp Business Platform’s webhooks provide your applications with real-time data, enabling you to build better experiences as you interact with customers. Ready to know more? Dive deeper into everything the WhatsApp Business Platform has to offer.
First seen at developers.facebook.com
Mark Zuckerberg Calls Apple’s App Store Moderation Rules a ‘Conflict of Interest’
Twitter Faces Ban Over Content Moderation, EU Chief Warns Elon Musk: Report
How to Create Effective Social Media Guidelines for Your Business
Building LinkedIn’s Skills Graph to Power a Skills-First World
Twitter Not Safer Under Elon Musk Leadership, Says Former Head of Trust and Safety
WhatsApp Update Allows Users to Include Caption While Forwarding Media on iOS: All Details
(Re)building Threat Detection and Incident Response at LinkedIn
Access Levels for Gaming Apps
Introducing the ‘Instagram Explore home’ Ads Placements via the Instagram Marketing API
Plug and Play LA announces program with Meta to Transform the Future of Business Messaging
Twitter’s Chief of Information Security Lea Kissner Exists Company Amid Mass Layoffs
Adding WhatsApp to Your Java Projects
FACEBOOK1 week ago
How to Send Interactive Messages with the WhatsApp Business Platform
FACEBOOK1 week ago
Hermit: Deterministic Linux for Controlled Testing and Software Bug-finding
OTHER1 week ago
Elon Musk Urged by US Senator to Better Protect US Users’ Data After Whistleblower Testimony
FACEBOOK1 week ago
Building Intuitive Interactions in VR: Interaction SDK, First Hand Showcase and Other Resources
OTHER2 weeks ago
Elon Musk Says Twitter Managers Can Approve Remote Work for Staff at Their Own Risk
OTHER7 days ago
Twitter, Other Social Media Apps Fail to Remove Hate Speech, Says EU Review
FACEBOOK3 days ago
How to Interpret Webhook Components in the WhatsApp Business Platform
OTHER2 weeks ago
Twitter Sued by Disabled Employee Over Elon Musk’s Ban on Remote Work