About this talk

In this talk, we'll look at some of the features of Orchard Core, an open source, community-driven, content management system built on ASP.NET Core. Plus a sneak peak of what's going on behind the scenes.

Transcript

So I saw this this morning, so I thought I'd... Well, in tonight's episode of Back to the Land, Kate heads to Devon to meet six business owners, including cider maker Natasha who is fighting to make her business a success. I can't believe you're actually working out here on a day like this. It's because I'm actually very excitable about this new orchard, which has been ravaged by hares and everything else. So I'm now here putting some girds on. - Clearly it is a brand new orchard. Have we sort of got you right at the start of this venture? - Absolutely. So, we literally planted these this year. - Right. - And the plan is, really, to try and make this a lovely, productive orchard with nature in mind. But mainly, we've jut got to secure our future. - So, I thought that was quite apt. And that was this morning, actually. Quick show of hands do we have any .Net developers, ASP.NET developers in the room? Oh, quite a few. Not as many as I thought. Has anyone heard of Orchard CMS? A few of you. All right, good. For those that haven't heard of it, it's essentially an open source, community-driven, content management system built on ASP.NET. But we don't want to talk about that. That was so last week. We want to talk about the new one, which is Orchard 2. If you wanted to learn about Orchard 1, go onto GitHub, and you'll see a bit more. Orchard 2 or what we've coined it as is Orchard Core because it's built on the ASP.NET Core platform. Which makes it cross-platform, Mac, Linux, and Windows. And obviously, we get a lot of the goodness from ASP.NET Core. What we're going to attempt to do in the next five minutes is give you a quick sneak peak of what we are working on at the moment. A lot of it will probably change because it's being worked on quite rapidly. And I'm only going to be able to show you a few features, obviously, because of time. When we initially run, we get to a setup screen. So I'm just going to give the site a name. And then we have Recipes. So Recipes are essentially start-up scripts, which you can author yourself. And I'm going to pick the Blog one. And, you can see, there's a Content Management one and a Software as a Service one. So, previously, with Orchard 1, a lot of people used Orchard 1 essentially like an API management system, which would control a native app or an Angular app or something like that. We've built that in out of the box, now. I'm going to pick the Blog one just for this demo. We also can use a number of different transactional, relational databases. And I'll come to the reason why we can do that now in a second. And we can give it a prefix. So, prefixes are useful if you want to host many sites in the same database. This is a full multi-tenant platform so you can have hundreds of different sites using the same database and the same instance. I'm just going to give it a live connection string. In fact, what I should do is use Chrome, which will have it already in. This is the HTPS stuff that someone was talking about previously. It automatically redirects to HTPS. Okay, so I'm going to take this connection string here. So I'm just going to take that. Give it a username, an email, a password just like that long. And click Finish Setup. And what that will do now is it will run that recipe and create the site for us. Now, normally, in Orchard 1 that would have took about 15 seconds to build. But because we're using the new platform, it's really quick. We have a sample blog with a sample post, and we also have an About page as well. So, looking at the code to this. So this is one of the recipes. This is the blog recipe that we've just ran. Which is just JSON, you can author these yourself. And you can see here we've also got some JavaScript in here that we can use. These are the modules that it's enabling. And you can see here we're creating parts and content items and so forth within this file. Looking at the layout file. So, this is the layout file for the Blog theme. And I just want to highlight a few things here. We make extensive use of tag helpers, and you can see them in use here. So we've got a standard script tag, and we're saying, "Bring me back jQuery, use the cdn, and place it in the Foot." Can everyone read that okay? Yeah? And the Foot is determined by another tag helper, which is the resource tag helper. And we can have some placeholders here, but we have one at the very bottom called "FootScript." So it's essentially saying, "Place that script in the foot of the site," or whatever that is. And that could be its head, and so forth. Tag helpers are essentially... Think of them as components. Or, if you use Angular 2 in any way, it's a mix between components and directives. So you can have multiple directives here. So we got multiple ones on use on a certain element. Or you create your own custom elements like we have here. And these all run on the server. And they pre-process it and then output whatever HTML that you want to output. So if we was to view the source, you can see that, if we try and find the jQuery... Now we can see that here we've got font also. We've got Google APIs. Oh, yeah, of course. Yeah. Good catch. Just testing you. So you can see here we've got jQuery being placed in the Foot and it's using cdn like we've told it to. But that could be multiple pieces of markups. People use tag helpers for Bootstrap so you can have, like, models, or things like that, or grids. You just open a grid tag, pass it some data, and it will do all the formatting and rendering for you. And the magic part of that is it runs on the server. We use a lot of those throughout the application. An example of one where we use is for content items. So here we can see we have a menu content item being rendered as a custom tag. And we're basically saying, "Render the menu content type. In particular, the main menu." Because we can have many menus on the site. One thing that was a bit of a bugbear with Orchard 1 was performance. And the main reason for that, it was very modular, and the pages essentially built up from loads of different component parts. And the database is highly normalized in Orchard 1. So what we wanted to do in Orchard 2 is develop for performance as a first class citizen. So what we've started to do is change the way the database works. So this is the database. And you can see here these are the tables that we've created with the prefix. So, I'll click on one of these. Content. And this is all the content for the site. For this site. And you can see that all it is is JSON documents stored within a relational database. And what we use for this is something called YesSQL. Now, YesSQL, again, it's essentially an ORM. Where it's an ORM for your standard POCO classes, your C# objects. And it serializes them automatically in the database for you. So this is totally optimized for reads rather than writes, nothing like the old Orchard. And then what happens is we create another table. So, for example, here we've got a user index table. And this highlights the things that we want to Query on that JSON document. So think of it as like a Lucene index, if you know of Lucene. So, here, we can see that I've elevated the username and the email, and then it links to that document, which is Document 61, which is the user information document. So you can see here we've got their password and security stamp and things like that. So, we can Query on this document using those properties. And that's how we would do that. What this gives us is lightening speed. So looking at the network. If we were just to do some refreshes here, we can see... This is the main. Let's go to a blog post. Here's the blog post. You can see here we've got a time-to-first-bite. Can you see that? It's 11 milliseconds. That's without any cache whatsoever. So I click on it a few times, and you can see that... 13 milliseconds. It's about 10 to 13 milliseconds on average time-to-first-bite. So that's the processing on the server. What we can do is add some caching to that. So what we've got here is donut caching. So this is essentially saying, "Cache the menu." Before I do that, what I want to do is quickly do a load test. And this is using GoBench, which is essentially ApacheBench written in Go. And this is essentially going to dispatch 10 clients and hit that blog post as hard as it can. And you can see here that the requests-per- econd is far under requests-per-second. Now Orchard 1, with fully cache, on a decent machine, was getting 400 requests-per-second maximum. So this is getting 500, and this is quite low because it's on my machine, without any cache. Without anything. Without doing anything at all. Let's run it again just to get a bit of an average. You can see here we've got 600. So it's thereabouts. And if we was to add this cache to the menu... And what this is essentially saying is, "Cache this menu item for five minutes. And stick it in the cache with the alias of menu, main menu." So from here, if we refresh the page... and we look at the time-to-first-bite now, we're getting under 10 milliseconds. It's a lot better. And it, obviously, will change every time you click on it. 8 milliseconds. So we've got a save in there. You can now run the same test again with the cached menu item we should see an increase because we're now caching that piece of content which is... Menus are a pain to cache because of, you know, selected states and so forth. So now we're looking at double the requests- er-second just by adding some basic dialogue caching to the content item. So we're getting 1,200 requests-per-second. As I said before, we're taking it very seriously. And what I want to do now is show you something that, actually, we only did yesterday. So I'm just going to log into the admin and enable the caching module. So, go into Modules, I'm just going to find the Response Cache module. And do a refresh. Now, if we look at... We're getting less than 1 millisecond in terms of time-to-first-bite. 0.61 milliseconds. If I do another test, any guesses? - [Audience] 2,000? - 2,000? Closest one gets a beer. Any takers under 2,000? - Fifty dollars. - 50,000. - Have I got to buy you a beer now? - So what you can see, we're taking performance seriously. And, you know, hopefully, this has given you a quick preview of what we're doing with Orchard 2, or Orchard Core. If you do want to get involved, I'd encourage you to do so. Go into GitHub, OrchardCMS/Orchard2. This is the road map. This is what is being done already. So we've got multi-tenants here, we've got some theme in, we've got authentication and so forth. We've got some menus, some live previews, and then we're looking to RC August this year. So, have a look. If you've got any questions, obviously, come and find me. And that's it. Thank you.