 Okay, hi Thank you for joining to my session today Offloading calculations from WordPress onto other services such as AWS and Google. So this is my title My name is Shin I create websites for my clients Clients are based in Japan and in Thailand. I used to live in Bangkok for two and a half year And now I'm living on a Japanese small island with 150 people so This is me working in Bangkok and This is the island I live now And This is my daughter cleaning the house Yeah, so This is my life and my life is totally backed up by WordPress the software and its community. I Try giving back to the community through translation and theme review and running events so events include meetups in Thailand Yeah, and on my island This is really small like five people. This was like a translation day and then This is the big one. Welcome Tokyo 2012 with 1400 people Yeah, so that's me and To the point High traffic websites and spiky access. You suddenly get a lot of access and WordPress So it's it's a bit tough sometimes when you get a lot of traffic. Maybe 10 people Come to your website within like 0.1 second then your WordPress might not work right so WordPress is a great tool to build websites and sub contents but when the website really grow then you need to think more and To deliver the content to the all the audience like all the time without failing So of course there are a lot of things you can do to like speed up your website or to to make it light But today I want to focus on Non-wall-press things. So these are the things you can do within wall press and There are things you can do outside and we I want to focus on like outside of the world press or PHP or the server so the base basic idea is Not letting like Don't let the world press do what what press is not good at or what press is not made for So these are things to offload Searching sorting showing related posts or related products recommending contents based on users preference and Logging lots of data such as like access log or security log or Bucking up itself. Yeah So when your website needs to really scale These things can be done inside WordPress, but when it scales you need to scale your website then you need to Do these things outside of WordPress So let's look at this model This describes how usual plugins work Plugins are included inside one big process the white one So when wall press is loaded Plugins hook into wall press right and then what it works as a one big process This is the like off-loading model So let's look at the pop-up boxes in the middle So I wrote Connector plug-in so they are connector plugins and the work itself. It's done outside of the world press I wrote micro service So you connect the world press core and The micro services through API so this is the basic idea to when you want to offload something and This idea is not new. It's a it's a really like common and old idea. For example, Akismet So Akismet plug-in does a lot of things in also inside one press like they have the admin page They are admin menu this spam comments like they offer like mark spam buttons But the judgment the core function the judgment whether a comment is a spam or not It's done outside of world press. It's done at Akismet server like a server hosted by automatic so When you want to know this comment is good or not then you Send information IP address and stuff like that to the Akismet server. They collect the data They know if they are good or not and they Give you the feedback and then it says it's a smile so you can delete them right, so Here Akismet plug-in is working as a connector plug-in you connect your work press and something outside of work press and We can find more similar like plug-ins like connector plug-ins In for example security fields most of the security plug-ins offer services Which happen outside of one press Such as like a blocking bad access like a blocking should Happen outside right when it reaches your one press. It's like no use. So it needs to happen outside and Logging and so on Also some of the features in jetpack plug-in They are the same concept you send data or you ask someone to do something they do they give you the feedback Okay, so cases offloading ranking popular posts Okay, so we want to show the popular posts below article and The post needs to be like this top three most viewed posts within these seven days in a category JavaScript or anything like Singapore under Slash and slash path. I mean example.com slash en slash So you can do that with WordPress too But to achieve this only inside WordPress Basically the plug-in needs to log every access like this one this access this timestamp and Yeah, this URL or ID post ID or stuff like that. You every access adds one new role to your database So what happens? You get million access a day then like million rows rows rows and That's really bad for scalability So then who should do this? logging and calculation like which are the best within this like Criteria or like the conditions So we have another software. We I think everybody use here So that's Google analytics So Google analytics is made for that. So we need to use that data This is a plug-in by Horike Japanese guy This plug-in fetches data from Google analytics through its API Can you see this? So with three posts and within seven days and post type is post category is JavaScript and we need to filter them with the path So it's going to be written like this and then You give it give this array to SGA ranking get data then you get the data and the data come from a Google analytics and this plug-in always caches the result because you don't want to Ask every time maybe once an hour All right, then you are not logging. You are not calculating that sort of thing is done outside At Google analytics service Okay, next one offload such related posts So what we want to do is these are like example like the cases so we want to look up the full text of an article and look for a really related post so Yeah, or we need to look at the taxonomy times and post meta too and But we don't need to have the perfect match like we want to look for contents even someone misspelled and rate the post with frequency rate so The usual search List just list if it has the contents has the words you search and Maybe you want to search products in your e-commerce website You want to sort by price or you want to search by price range and then these kind of things are Really bad for your performance because for example the price In most cases prices are saved in like meta field maybe post meta And they are not indexed in my school So if you want to sort like top five then what it's going to do is okay Let's look at all the posts and which has the post type product And let's look up to the like meta table and then list everything and sort it You can imagine how slow it it's going to be so It's really difficult And This is a plugin for that elastic press it's written by 10 up and We have elastic commerce related items of those are how to get and he did okamoto and more and elastic commerce search form or WP simple elastic search So elastic search is a search server. It's a software It's open source project and you can store and pull data through restful API Interface so it's good for full text search or relevant result result or fuzzy matching not perfect matching and Inside world press you can use it for like sorting searching Especially like searching like metadata or meta You know taxonomies or terms or time meta and you you just put the data and you tell How you want the data back then it's really quick So maybe let's look at a demo So it's that demo website So here we have a A lot of products and then It says hi to low We go back to yeah default sorting It's a menu order then we want to Sort this by popularity Or rating or maybe the price high to low. Yeah so This calculation is not done inside world press. So it's asking To elastic search and then they give you back the answer you render the result so next caching so The easiest way to be happy with high traffic is caching and especially we like caching on CDNs So caching can be done inside like PHP you cash everything into your database you don't query but you just get Something from the day like get the HTML from the database. That's number one or you can Like offload that to server level like vanish or nginx proxy caching But it's still happening inside your server right so access comes to your server world press. Maybe it doesn't move But your server is working and if you cash your HTML like images Style sheets and scripts and also the HTML then Access doesn't reach to your server Then you don't need to work then you need you can keep it really cheap So the problem is how to control the cash So there's a plugin for that the C3 cloud front cache controller So we cash almost everything including that generated HTML. So before we were caching contents on nginx proxy caching server But after cloud front, it's a service inside AWS. It's a CDN service. It's a global one Then we found it's it's a lot easier to do there Yeah, so this is the plugin we use to control the cash on the CDN Cloud front did it delete Cached content from the CDN when you click delete button, of course Or when you publish something or you update your contents, then it just delete everything and Backups storage and more so we want to do outside of one plus these kind of things So this is a like I map this is a map which maps like what is done where and These are like AWS icons, but here you can see many things are offloaded from WordPress So there's our AMI or This one is it to server So there there is PHP and your WordPress is there and then you have my sequel That's but it's outside of your server. So it's outside of your OS It's there all DSDB instance. So it's a Amazon's Database service so you can just use the service You don't need to set up some something like server and you install OS and your OS Needs this this this middle where you don't need to do that. You just use the service And that one will back up everything like you can roll back to any point Which means you don't need to back up your database You don't need to run like WPDB Export and send it somewhere and all things stuff. You don't need to do that. You just leave that there and The medias are stored in Amazon S3. It's a storage service. It's cheap so instead of sending your Uploads like medias to your WP content slash uploads slash 2016 something something you do that but you sync it to Amazon S3 Then it's really difficult to lose contents from S3. So which means you don't need to Do backups right like it's backed up there And you can create backup of backup to I mean S3 backup to and then And then your source code like themes and plugins and one press core or other files They can be like anywhere like git or something right then you can Like switch anything like you can switch the database you can switch the easy to serve itself because PHP runs and you have your source code and you have tested then everything works So backup is there and you have the cloud front So if we add here the Google analytics simple GA ranking or other tools like you can offload your comment to maybe discuss or Like Facebook comments, that's also like you're offloading something outside and Other like a synchronous tools Then I think we'll press look like this. So this is the model we saw before You have one press core and connect our plugins and other services like Google Amazon Discuss Facebook and stuff like that So but this one is like we we look the world press as a like hub or it's a it's the center but Maybe we need to change different think differently So this is about building micro services So system of like multiple components like and then Components they work like individually like independently. They they can work alone and Each components are loosely coupled through a restful API or some kind of API Then This one should look like this So this should be it's service sees model. I name this So but you have a lot of things you can use Right and then won't press can be one of them So think like won't press has now WP API It's to communicate With others right so we have yeah, I love won't press won't press my life, but We don't need to think like okay. We start from one press. Can we do this with world press? I told you like let's don't do this Let's not do this, but like how can I offload stuff? This is the like second stage may be like the last stage would look like this we can have a lot of things we can connect them each and One of them is one press. This is the model and One thing I like about this model is like if you do this then you can come back to The real good point of world press. So what presses mission is? democratization of publishing which means like everyone can publish what they want Anyway, and freely so and the thing we want to do is Like deliver your contents your thought your products to someone Then it's not like a logging or like a security You don't want to care about security when you want to tell something some somebody something so we need to We this way we can like really concentrate this way or even this way We can really concentrate on what one press Offer us or what we want to do with one press so The talk started from how to offload how to like serve the high-traffic website But if we choose this model, there are a lot like we can like come back to the one press strong point And that was my talk today Yeah questions I think you have quite an interesting life Thank you