Introducing Wolfram Web Engine

Carlo Barbieri from Wolfram's Engine Connectivity Engineering Group walks through the Web Engine, a technical platform for deploying Wolfram applications. The talk covers its modular architecture, security features, and how to run it on Docker or Raspberry Pi.
Chapters
Hi, my name is Carlo Barbieri, I work in the Engine Connectivity Engineering Group and today we're going to introduce Wolfram Webengine. Okay. Hi, I'm Carlo and today we're going to introduce Wolfram Webengine or wwe. Basically this is the outline of the talk. I'm going to first explain what it isn't, what it is, what the architecture is, how to use it, where to deploy it, and then I'm going to answer some questions, if there are any. This is not going to be a terribly technical talk because it's more of like the introduction of new product. So basically I'm going to speak more about its features than how the sausage is made. So wwe, it's kind of an unfortunate acronym, but it's very important that we stress that we do not support any gratuitous violence. On the other hand, this is the real thing. So Wolfram Web engine is standards based. It's built on top of the Java Servlet interface. So since Java runs on there was a huge spike of devices on which Java runs recently, it was like 3 billion for the longest time. And now if you install Java it says like 13 now. So it's great. Runs on a bunch of different places. We have been developing it with tomcat, but the Servlet interface is very generic and it's not just tomcat. So I think the bigger limitation is really whether you can run a kernel alongside it rather than Java. And interestingly, this is like the successor of Web Mathematica work done by Tom maybe 20 years ago and then Todd. So I'm standing on the shoulders of giants and we've added support for more modern deployments, not just JSP but also API function, form function, et cetera, et cetera, et cetera. Yeah, so since it's based on Java Servlet interface, you basically have the keys of this thing is fully modular and configurable. If you want to run it alongside other Java based web apps, you can. If you want to, you can put it on a server where there is another thing running alongside it, maybe your own database. And there's another web app that uses Django, you can do that. We don't have users out of the box, but there is no reason why you can't do that yourself. So for example, there's one thing I'm going to show you. Like tomcat has security constraints and so you can give it URL patterns and then connect it to an LDAP database and by just using stuff that we haven't done but The Apache foundation has done. You can get more security and login capabilities without, you know, it's just, it's just, you know, if you use standards, then you can extend the thing by using, you know, open source technology and etc. Sure. So I'm going to repeat the question. ITAY wants to know what no user means. It means that it's not the cloud really, so it doesn't. You don't have to make an account to log into it. The way it works is that at the bare minimum, this is just one API endpoint and whoever can access that URL can do the computation on the API. But you can put security constraint through tomcat, or you can put it behind a proxy of some sort. Whatever you want. Because it's based on standards. There are currently no limitations on the Wolfram language functionality. That means no sandboxing. No, you can run things like run process and start something else. You can do run process of RM RF and then destroy your whole server. If you're accepting unsanitized external user input, that stuff is going to happen to you and whatnot here to save you. So it's a product for grown ups, but you can really do whatever you want. It doesn't support cloud notebooks. If you want cloud notebooks, get an EPC or the public cloud. And yeah, and then that part I said you can install it alongside other stuff, which we don't encourage you to do if you don't need it because obviously since it's very unrestricted, you can go and delete the rest and Ouch. This is going to be like every slide. I'm going to get shocked. Okay, so first thing, we've revamped Service Deploy that was introduced for Wolfram Web Engine. I personally find that. Sorry, this was interest for Wolfram Application Server. I personally find that the version of Service Deploy that came with Wolfram Application Server was a bit. Let's say it's not Wolfram language enough in that instead of giving you first the automatic stuff, you always had to support a big association stuff, saying, this is the endpoint, this is the node, blah, blah, blah. On the other hand, this is much closer to how cloud deploy works. So basically the way it works is. Let's see if I have this. No, it's okay, it's not. Let me start it. So this is gonna look. Where is it? Bin. So this is the. So you can really see it's for grownups Catalina run. And then you see all this. Yeah, it looks a bit like the Matrix. It's cool. Makes me look more like a hacker, but it's okay. So once, once you start the thing, then you can service connect to it. And I mean since, I mean it's still in the same session. It didn't ask me for the password, but I set up a security constraint and it has username and password. In this case it's basic Auth. Basic HTTP auth. But since Tomcat supports more than that, you want to use ldap, you can set up a security realm and make it talk to your LDAP database or whatever. So once you've done that, you can do a service deploy of something. I hope the server is up. This will create a UUID if you haven't provided a URL and you can go visit this. I hope that the kernels, yeah the kernels are warmed up. So this is now running locally on my machine and basically so you can do it anonymously, you can give it a name. Then you do this and you say champagne and you get eventually a map of champagne. I mean this still has to talk to like the geotile servers are not on my machine so it's not going to be super fast because. Because of APIs, not because of me actually let me check on what wifi I am. Yeah, so yeah, you see this is Champaign and next to it Urbana, you can deploy files. So in this case, sorry, static resources. So in this case this is like a random image that we have deployed and basically it figures out what, you know, just like export from the URL says PNG and it figures out the format or you can actually send the whole file and let's see if this works. Taking a picture of me right now, current image and boom, it's on the server. And then this is new. I mean it's not new new because it worked in the cloud seven years ago, but it was never supported on from application server and I think it's kind of an important feature. So this is URL dispatcher and for this I'm reusing probably the most controversial presentation we've done at WTC. We did it with Ricardo in 2015. It's a Vatican website. We've received many complaints that this was disrespectful. Apparently the image of the Pope doesn't work anymore. Let's see if we have older popes. Yes. And this supports things like a form to write an email to the Pope or directions from to the Vatican. Let's pick something that is on the same continent, let's say Sofia, Bulgaria. And it's going to Compute travel directions to the Vatican from Bulgaria. So yeah, so this is like. Okay, so this supports all the things that the cloud does except for notebooks. So all the form pages and even multi step forms, uploading files and saving them. Again, it's your own machine. So if you want to let users put like gigabyte size files on your machine, there's no limits on that stuff. You actually have to set them up yourself. Okay, so the thing I'm showing right now, it's running on bare metal, it's running on my machine. The way you do that is you use your favorite package manager. I'm using Brew here you do Brew, install Tomcat, then you figure out what it was installed and then you just have to copy a war or a directory over there. It's the way you usually install this kind of servlet things. What happens is then you get a folder like this and in this folder you can see the deployments we had. So for example, in the resources folder you can see my selfie that I took earlier. And here there's stuff like delayed now that we were looking at earlier. The Vatican thing is kind of big. So it's an MX file because it has the same. I don't know if we've ever talked about this in cloud talks, but basically for optimization reasons where you're deploying something that is quite large, it makes more sense to load it as an MX rather than to parse the whole M or WL plain text language file. So it's way more efficient to load an mx. So yeah, this is all very standard, very standard stuff. It's in a folder. What's the advantage of it being in a folder? That if you, since you are all adults, you can take this and r sync it to another server or you can use something like a GitHub repo or not Hub necessarily git repo where you have your deployment and whenever you're ready to do a new release you can set up continuous integration. Because it's a folder, it's not like something opaque that sitting somewhere else. We're using files again, this stuff is like some of you have been users of long term user of web Mathematica. These XML files contain things I don't know if you can read but like tell you how many kernels they have available, which Mathematica version to point to. This stuff hasn't changed from Web Mathematica and the web XML stuff is bug standard servlet specification. So you can set up here the various security constraints and whether what URLs. Point. What servlet, if you want to use. So, for example, images are not served by our servlet. They're served by the default Tomcat servlet. So standards. Standard. Standards all the way down. Yeah, so I said that you can also, I think something that is very interesting is that you can iteratively build your web app by using Service Deploy, which has the advantage of bringing over the definitions in the exact same way that Cloud Object, Cloud Deployed, Cloud Publish does. So you get the exact same behavior, it's the same code path. So once you've built an app that works and you're confident with all the definitions, et cetera, then you can use that in our Sync it somewhere else, for example. So it's kind of a hybrid way of doing things. Docker. Everybody likes to use Docker nowadays. We have a Docker image. So, like, there's some. I'm going to launch this and I'm going to try and unpack this a little bit for you. So here I have two open ports. One is the debug port, that's the 8000. And that means that. Well, you probably won't do that, but I can attach remote debugger to the remote JVM and the other one is the port 8081 is the port on which I'm going to serve. That maps to internal port 80, then V. Those are volumes. So one thing that I'm doing is that I'm basically sharing the licensing information with a folder that is on my file system. When the docker gets invoked, I don't have to modify the container to have the license information. I'm just syncing a folder with it, the same thing I'm doing with the web app. So what that means is that even though this thing is running in a container, I will still have a local folder where all the deployments go if I want to, then take that and rsync it somewhere else, etc. The folder is just a volume, so I don't modify the container at all. In this case, though, you can with Docker Compose if you want to create another container. But if I just want to keep reusing the same container and serving different stuff, I can just go with an editor and change the files. And this is what I'm gonna. So let's connect to this1 on 8081 and again it remembers the password. Let's see. So this is going to be a little bit slower because I have one of the new ARM Macs and this is like the. I did this based on the Wolfram engine container that is already on Docker Hub and that only works on AMD 64 for now. But that's going to change, especially if you make noise with the. So it's a little bit slower and I just set it up so the kernels are still warming up. So this might take a little longer than it did for the other one and. Yeah, but in general, what I wanted to show you in the meantime is that there's like the date. How do I get the date thing that doesn't have an extension? It's basically. It's a folder inside there's a WL file that contains delay now. So now it works. So now the kernels are alive, you can see the date updated. And the whole thing is that basically now that I know where the file is on my file system, I can just put something in it, but it's not the date. And if I refresh the page I will eventually. But again, remember, this is emulated and get a form function. Yes. So basically seamless communication between outside of the container, inside of the container. Very easy to do Web development for this. Yeah. Remote server. So now if the server is not sitting on your machine, the workflow is the same and you can just deploy something to it. First you connect, then you deploy something to it. You get an API function, API function wants parameters and you can something bigger and you get the stuff that. Why is this useful? Because maybe you have a big large website that you've done with a bunch of stuff that is not Mathematica. But there is one thing that you just can't do with Java, because Java doesn't support very large integers or cannot factor polynomials or whatever. Like I've heard people who are doing things like doing code equivalence for assessment of the answers of their students and you know, the whole front end is built using React. But there is just that last thing that you can only do with Wolfram language. And this is why you put some API there. And so yeah, and you can. This is like a machine that has four cores and four kernels. And now we're launching a computation that is at the same time hitting it with 16 requests. So basically four requests per kernel and it took one second, but it knows how to queue them and how not to choke when you get more requests than kernels. And so it's good for even larger volume operations. And you might say, oh, but you put this on a beefy machine somewhere. No, it's here. It's running on raspberry PI. So this factorial API is just running Raspberry PI and it can get hit with 16 requests at the same time and still not choke. So you can really, really, really run it anywhere. And yeah. Ouch. Okay, so yeah, I think where's the arrow? How do I go forward? No, I think that's pretty much it. And like, I have plenty of time left. The person after me, which is also me, is going to be very happy to have more time. But yeah, I'm happy also to take questions or take this time to do the poll because the poll is actually really useful, I guess, for us to figure out what you use the cloud for. Yes. Okay, so I'm going to repeat the question for the folks at home or for the future folks watching this. So right now we have, I think you said we have Web Mathematica. We don't have Web Mathematica anymore. We have Wolfram Engine, which doesn't serve stuff. We have Wolfram. Wolfram Engine doesn't serve saf. It's just basically a version of Mathematica without the front end, more or less. Then we have Wolfram Engineering, Wolfram Web Engine, which is the simplest way to serve your web content using Wolfram Engine. And there is also another version which is Wolfram Web Engine for Python which has been out for a while and it's open source. You can go check it out on GitHub. Ricardo wrote it there, so if it doesn't work, go to him. And then was is basically like a whole cluster of this of Wolfm Web engine. So was is something where if you need scalability, you need like it starts out I think at eight nodes. So it's like you have really a lot of stuff hitting your server. You need to have multiple computers and a load balancer. That's what was does. Of course, if you know how to build a load balancer yourself, you can buy this and build your own load balancer. And basically this Wolfram Web engine is kind of the underlying technology that we've also been using for building the cloud itself. So like in the end also EPC has this inside, more or less. So yeah, does that make answer your question? And so yeah, if you want something beefier, getwas if you want something beefier and notebook, get an EPC. If you are serving two API functions, this is good for you or 10. Yes. So Joel is asking, can you load the code from this that you've deployed? And the answer is absolutely yes. I mean you have a folder of stuff you can put really whatever code you want there. So if you don't want it to be in the root web app thing and so that it's also visible to user, but you want to put it somewhere else in your file system, there are no limitations on the file system. So if you want to need some other package that you saved in a folder that's not visible to end users, there's no limitations to what your kernel can read on disk or write on disk. You have to put in place those limitations. So yes, if you have a large package that sits in a directory, you can get it and then run the API with that code. So it doesn't have to leave all in the deployed object. Yes, I think, yes. I mean it's again, load balancing strategies. I'm not entirely sure that on a single machine you have any. You just have a pool of kernels and. Right, Todd? Yeah, yeah. So you know, so you. Again, if you know what you're doing and you put it somewhere, then it will fit in that. Because it's just another Java servlet. If you don't know what you're doing, probably you should buy WAS because we've done that part that's. I mean it's. The whole point of was is to get you from this to load balancing, etc. The limitation of was is that as you said, if you have a whole infrastructure of other stuff WAS has to run separated on their own machine, separated from that. And so you know, if for whatever reason you want to, you're crazy enough that you want the database to run on the same node as the, as the compute node. You can't do that with was, but maybe that's just bad practice. So maybe you should keep them isolated anyway. But yeah, if you want to shoot yourself in the foot here, you very much can. So. Yeah, yes, Anton, you. Anton. So the question is, can we have embedded notebook with this? No, we don't have notebooks here. So the part of code that does all the rendering, the document model, etc. That's specific to EPC. So you cannot do that. I wonder if we could set something up where you have an EPC and you point this as a remote kernel. So that is something doable, like for example, a Docker image which. Yeah, but you still need the cloud for the, for the notebook Chrome. But then maybe you can tell that if it's an APC that's more configurable then you can tell it to point to kernels elsewhere. Yes, Bob. So the question was, sorry, I repeat, for the folks in the future, is the kernel stateful? Yes, but I mean that can be changed. I mean out of the box. If you pollute the state of your kernel with stuff, then you keep the data in the kernel state, but that can be changed. So Anton asks, can we have different kernels for different users? And there is a way to do that in that. So basically. But you have to set it up. So basically in the MSP configuration file you can set up kernel pools. So you would make kernel pools of one and then map them. I'm pretty sure you can map them to URLs and then you can give a security constraint of that URL so that you make something like localhost Anton, and only you have the password to that. And you get your own kernel pool of one kernel or four, I don't know. And I get Carlo and I get another kernel pool. Yes, it's what it's available for use almost. No. Yeah, no. This week maybe. No. Like there are a couple of kinks that we need to iron out in terms of especially the service deploy thing is not yet completely finished, but if you're using it with Rsync, it's pretty much ready. And in fact the fine folks at WTG are already, you know, starting to work on it on several projects and we are talking about. So like for example, the Docker image should be put online very soon. Yes. Now. Yeah, it will go up soon in the Docker hub. Official Docker hub of Wolfram Research. Yes. Paul. Okay. The licensing is stuff that is still being figured out by people who have different skill set than mine because I. Unfortunately I'm not very good at this. But the idea is that this is going to be. So basically you need to get a license per kernel that is much cheaper than EPC or was licensing per kernel and it's closer to what. So it's basically going to be like Wolfram Engine. So let me start again. Wolfram Engine is free to try out. Not Wolfram Web Engine, Wolfram Engine. So if you want to use it for production use, you have to pay a little bit more to get Wolfram Engine. And this is probably be either the same price as Wolfram Engineering for production use or a bit more than that because it's for web use. But the idea is that you're not gonna buy the servlet part. You're gonna buy kernels that have a special entitlement. This is the idea. Okay. Okay. I just wanted to offer a comment about. You know. Yes. So for those of you who didn't hear it. I had the experience of being in a small college where they gave the keys to the server, to mathematicians, and obviously they had only one server, so everything was running at the same time on it. So for them, it's attractive whether or not it's a good idea. It's up to them to decide. Again, this is a product where we treat people like responsible adults.
More from Guy

Cheryl Strauss Einhorn | The Human Edge: Smarter Decisions in the Age of AI | Talks at Google

Rachel Glennerster | Innovation and the Center for Global Development | Talks at Google

Rebecca Winthrop | Rethinking the Purpose of Education in the Age of AI | Talks at Google

Dr. Robert Wachter | A Giant Leap: How AI Is Transforming Healthcare... | Talks at Google






