<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Damien Pobel</title>
    <description>The latest articles on DEV Community by Damien Pobel (@dpobel).</description>
    <link>https://dev.to/dpobel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1049470%2F1281ee84-066c-4844-a4ad-36202a414f82.png</url>
      <title>DEV Community: Damien Pobel</title>
      <link>https://dev.to/dpobel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dpobel"/>
    <language>en</language>
    <item>
      <title>Why do we check the number of external API calls in our audits?</title>
      <dc:creator>Damien Pobel</dc:creator>
      <pubDate>Wed, 12 Jul 2023 07:27:19 +0000</pubDate>
      <link>https://dev.to/front-commerce/why-do-we-check-the-number-of-external-api-calls-in-our-audits--4o3</link>
      <guid>https://dev.to/front-commerce/why-do-we-check-the-number-of-external-api-calls-in-our-audits--4o3</guid>
      <description>&lt;p&gt;On most of the projects built with Front-Commerce, we perform an audit. Without surprise, these audits are conducted on the basis of a checklist. The first part is devoted to performance and the very first criterion is to evaluate the number of external requests necessary to build the most visited pages when everything is cached. The point is to target zero external request to generate those pages. Maybe you wonder why we check that or why we give it so much importance.&lt;/p&gt;

&lt;p&gt;This &lt;em&gt;Performance&lt;/em&gt; section is introduced with the following sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Performance is essential to improve user experience, but also to reduce server load and thus increase the site's traffic capacity.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So the point of the whole section is not only to increase the performances i.e. in that case, the time it takes to generate a page but also to increase the scalability of the application i.e. &lt;a href="https://en.wikipedia.org/wiki/Scalability"&gt;according to Wikipedia&lt;/a&gt;, &lt;q&gt;the property of [the application] to handle a growing amount of work&lt;/q&gt;.&lt;/p&gt;

&lt;p&gt;To measure the number of external requests, you can use &lt;a href="https://developers.front-commerce.com/docs/2.x/reference/environment-variables#debugging"&gt;one of our debug flags&lt;/a&gt;. For instance, here I'll use a very basic setup where Front-Commerce is connected only to a Magento2 instance, so I can add &lt;code&gt;DEBUG=axios&lt;/code&gt; in the environment to have some information about external requests. Depending on your actual setup, you might need other values to also count requests to Prismic or any other external service.&lt;/p&gt;

&lt;p&gt;Also, we are mainly interested in the most popular pages of the site. Commonly, the homepage is most visited page. By default, we also check the category and the product pages. Depending on your project, this list can be slightly different.&lt;/p&gt;

&lt;h2&gt;
  
  
  Number of external API calls versus performance
&lt;/h2&gt;

&lt;p&gt;Note: &lt;em&gt;Performance&lt;/em&gt; is a very wide topic. By &lt;em&gt;performance&lt;/em&gt; here, we are looking at the time needed to generate a page server side. This is very easy to measure with a &lt;code&gt;curl&lt;/code&gt; based command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;time &lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; http://example.com/my/url &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a Front-Commerce setup configured without cache and connected to a Magento2 instance, 27 requests to Magento2 APIs are needed to generate a category page. Each of these requests takes a significant amount of time, sometimes several hundred of milliseconds. While when caches are enabled, if everything is in cache, no external request is made.&lt;/p&gt;

&lt;p&gt;Without surprise, the time needed to generate the page is completely different:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;without cache, on my local setup, it took between 5 and 6 seconds;&lt;/li&gt;
&lt;li&gt;with everything already cached, it took between 200 and 300 milliseconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's 20 times faster! The example is a bit extreme, but I guess you get the point. Also, without external requests, the response time is somehow similar to any external API call. This means that if on a page you have one external API request left, getting rid of it might divide the response time by two. Worth a try, don't you think?&lt;/p&gt;

&lt;h2&gt;
  
  
  Number of external API calls versus scalability
&lt;/h2&gt;

&lt;p&gt;Measuring the scalability is harder. It is done with load tests that involves running some scenarios to simulate traffic peaks (usually inspired by past events) in a production like environment. That's definitely not something you can do reliably on your local environment in 10 minutes. That being said, we always see a clear correlation between the number of external requests and the scalability of the application.&lt;/p&gt;

&lt;p&gt;Commonly, the target of those external requests (the Magento2 instance in my previous example) becomes the bottleneck of the application especially if some popular pages requires several API requests to the same service i.e. one page generated by Front-Commerce entails &lt;code&gt;n&lt;/code&gt; requests to one external service.&lt;/p&gt;

&lt;p&gt;Depending on how Front-Commerce is hosted, it can also be the bottleneck because it will be &lt;em&gt;busy&lt;/em&gt; waiting for some APIs to reply 😀.&lt;/p&gt;




&lt;p&gt;The conclusion is simple: &lt;strong&gt;when it comes to external request, the less the better&lt;/strong&gt;. After having said that, it remains the hard work of optimizing the application and the recipe is classic:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;is the external request strictly needed ? In some case, it might be an opportunity to discover useless code or to discuss feature;&lt;/li&gt;
&lt;li&gt;if it is strictly needed then you need to add more cache to the application either &lt;a href="https://developers.front-commerce.com/docs/2.x/advanced/graphql/dataloaders-and-cache-invalidation#what-are-dataloaders"&gt;by leveraging the dataloader mechanism&lt;/a&gt; or by using &lt;a href="https://developers.front-commerce.com/docs/2.x/prismic/resolver-cache"&gt;the cache at resolver level if your project embeds content from Prismic&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>frontcommerce</category>
      <category>performance</category>
      <category>scalability</category>
      <category>magento</category>
    </item>
    <item>
      <title>Some challenges of being the editor of a software intended to be integrated</title>
      <dc:creator>Damien Pobel</dc:creator>
      <pubDate>Fri, 24 Mar 2023 08:00:00 +0000</pubDate>
      <link>https://dev.to/front-commerce/some-challenges-of-being-the-editor-of-a-software-intended-to-be-integrated-3dg7</link>
      <guid>https://dev.to/front-commerce/some-challenges-of-being-the-editor-of-a-software-intended-to-be-integrated-3dg7</guid>
      <description>&lt;p&gt;Essentially, Front-Commerce is a software meant to be integrated by developers so that a merchant can sell products to its customers in its own online store and even &lt;a href="https://www.front-commerce.com/e-commerce-replatforming-big-bang-or-progressive-migration/"&gt;without having to completely change an existing e-commerce stack&lt;/a&gt;. While this is probably the simplest definition of Front-Commerce (more or less the one I use to describe my job to my family and friends 😉), it hides some challenges we face every day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three targets: developers, merchants and customers
&lt;/h2&gt;

&lt;p&gt;The first challenge is not really technical. As stated in the introduction, we try to address three main personas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the developers integrating our solution to create an online store for…&lt;/li&gt;
&lt;li&gt;a merchant willing to sell something to…&lt;/li&gt;
&lt;li&gt;a customer seeking a product.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anybody having at least a small experience as a software editor knows that properly addressing one persona can already be challenging, so you can guess what it is like with three, even if they don’t necessarily want opposing features, more targets mean more constraints.&lt;/p&gt;

&lt;p&gt;Let’s take a deliberately extreme example 😃 They all want a performant store.&lt;/p&gt;

&lt;p&gt;The customer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I want a performant and great shopping experience even in the middle of nowhere with a low to average 3G connection.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The merchant:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Can I have a great shopping experience for my customers? And also, I want to put very high quality photos and videos online. In addition, I want my pages to be always highly up to date with customer specific and very dynamic content. And next Friday is Black Friday! The website needs to scale, it’s the biggest selling event of the year.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The developers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The merchant wants a performant and scalable website. Is your software doing that out of the box or can it be done by turning on a setting?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I guess you get the idea, each target adds a set of constraints. It’s no  surprise that pleasing  everyone is difficult but it’s also a stimulating challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extensibility
&lt;/h2&gt;

&lt;p&gt;As a software meant to be integrated by developers, Front-Commerce needs to be extensible so that it can serve different use cases. The most obvious reason is that each merchant wants its own customized store implementing a dedicated shopping experience.&lt;/p&gt;

&lt;p&gt;In addition, each project needs a specific set of features and while we try to support as many as possible out of the box, having an extensible architecture allows the developers to fill the gaps. As far as I’m concerned, it’s always a pleasure to see very unexpected or specific features nicely implemented even if I would never have imagined it could exist.&lt;/p&gt;

&lt;p&gt;It’s also worth mentioning that in the world of composable architectures and &lt;a href="https://www.front-commerce.com/what-is-headless-commerce/"&gt;headless commerce&lt;/a&gt;, extensibility is a key feature.&lt;/p&gt;

&lt;h2&gt;
  
  
  Backwards compatibility and &lt;em&gt;upgradability&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Being able to implement a project is nice but that’s only the very beginning of the story. At some point, new features and fixes for bugs will be needed. The challenge here is to be able to deliver those without breaking anything.&lt;/p&gt;

&lt;p&gt;On a practical level, that means we try to follow &lt;a href="https://semver.org/"&gt;semantic&lt;br&gt;
versioning&lt;/a&gt; by regularly providing patch releases containing only bug fixes and every six weeks, we release a minor version with new features. Those minor versions always have &lt;a href="https://developers.front-commerce.com/docs/appendices/migration-guides/"&gt;a migration guide&lt;/a&gt; to make the upgrade process as frictionless as possible. And what about a major version? In the last couple of years, we have not released any, but I’ve heard that something is cooking 😇&lt;/p&gt;

&lt;p&gt;In the code, this has a quite deep impact. When changing code, we have to keep in mind both existing projects using our software and new ones. We also have to think about how APIs are being used before we can make any changes to them. This forces us to carefully encapsulate our API’s to reduce their surface as much as possible. This has a tendency to limit the extensibility and the versatility so as usual when it comes to code, the key is to find the right trade-off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Anything else?
&lt;/h2&gt;

&lt;p&gt;Oh yeah, I could have approached the support, the documentation, the developer experience or the dependency management to name a few. This will probably be the subject of another post…&lt;/p&gt;

&lt;p&gt;In any case, all this is a part of the context in which we build Front-Commerce and where we try find the best solutions or trade-off. As usual when it comes to our product, we are always seeking feedback, so don’t hesitate to contact us if you have any remarks or comments. This can only make the product better.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
