July 25, 2017

JXTA & Business – The Catalog

JXTA Catalog – Saving Money or Better Business

There are a few that stick to the old tried and true. The nice thing is that the adventurous have a competitive advantage. The adventure seekers and mavericks are better thinkers too because learning exercises the brain and keeps it humming.

JXTA is a very new paradigm (20 cents) and not always simple to grasp and apply to business problems. Throwing out old client server ideas and replacing them with P2P solutions takes a little effort. Lets look at an online catalog for example. Some hard thinking ahead. Turn back now now if you are faint of heart.

Catalogs are not hard to implement on the web. Get a good shopping cart and you have it. One thing we would like to get rid of is the cost for hosting and bandwidth. It is expensive to run a web site that can serve millions of hits. But we would also like to get our customers together for contests, games, chatting, and even to help or support each other (a topic to be covered in future).

Look at the components of a catalog: pictures, descriptions, prices, on-hand in inventory, shopping cart, order processing, credit card processing, order status. P2P is not going to replace every function. Credit cards, order processing, order status, and on-hand in inventory need to be done in part at the data-center, in the servers. The peer can get the request ready though. Our unavoidable contact with the back office are done with a web service or even through a traditional web page. But what am I saving?

Let’s Go Shopping

Think about how most people shop. There are three modes: browsing, restocking, and impulse buys. All three can occur during a shopping experience. Mostly though, the user is moving from page to page, downloading your catalog’s pictures, descriptions, and the navigation buttons, banners, backgrounds and other HTML flotsam.

What is happening? The user is downloading and re-downloading lots of data. Very little other work is done until the user wants to add something to the shopping cart, paying for the order, or looking at older orders. Essentially 95% of your bandwidth and hardware at the data-center is dedicated to just delivering copies of the online catalog. Worse, most of this is duplicated multiple times to the same user and then duplicated again for every customer.

So, the catalog looks like it might be a place for optimization. By giving each user their own copy, the size of your web operation is reduced by 95%. Sound good? But how?

First, use the P2P network to distribute the catalog. We could do this in the simplest way possible by just storing the HTML on the user’s machine. The P2P application would look at other user’s computers to see if they have the most up to date pages. This is like a web cache on steroids because your web server is not called until absolutely required.

Getting Your Neighbor’s Copy

Distribution of the catalog is a little tricky. When the application starts it sends out a signal to other peers to see if there is a new copy of the catalog. When the catalog is older than it should be, the web server is queried for updates to sections of the catalog and those that get the copy become distributors for the rest of the network. Very quickly there are thousands of exact copies of the updates available for others to update their data.

The ultimate version of the catalog would be a little more complicated. By using Java to create a full-blown application even the shopping cart and other functions can be implemented on the client side. Only the ends of transactions or queries need to be implemented as web services.

Who Said Java Was Slow?

But isn’t Java slow? Well, how slow is a web page through a slow connection? Java is not slow in any case and even if it were, anything is faster than most web page requests. Plus you have the freedom to add all sorts of client side tools, business intelligence, bells, and whistles to enhance the experience and increase profit.

Fresh Prices

What about the pricing of items and discontinued products? First, customers are far more flexible than many give them credit. They accept change – the don’t always like it, but they understand. Next, understand that prices for most retail goods do not change that often. Even sale prices are usually set far in advance. For volatile prices we update them at checkout time(Amazon does this with special pricing). We can also update the price changes at intervals that can ensure that the new prices are fetched either from another peer or a web service at a rate higher than catalog content. If you are extremely paranoid, the updated prices could be fetched each time the user starts.

Scaling the application is different with JXTA. Since the brunt of the work is done by the customer’s computer rather than your servers, the scaling of the infrastructure is proportional to its contribution rather than 100%. There are some JXTA scaling issues, but these relate mostly to tuning and how the P2P network is used. Since JXTA has a notion of super peers to help increase the efficiency of some operations, you may want to add a few to increase the efficiency of the application. More about super peers in another blog.

More Bells and Discounts

There are other benefits to the P2P/Web mix. Here are a few:

1. One computer language – No need to mix javascript, DHTML, PHP, Perl, Flash, etc.

2. Auto Software Update – Software distributed with the same system.

3. Works On Laptop – Users can use the application without connecting to the Internet. The final sale can be queued for later transmission.

4. Reduced bandwidth cost – Peers talk between each other rather than through your data center. You only pay for the final transaction – not the entire experience.

5. User to user connectivity – Users can chat and share info like product choices like an instant messenger application with more features and without impacting the data center. This is great for products that have communities like collectors, hobbyists, and are passionate about your products.

6. Local Storage – A user’s own computer is used to store things like past orders, credit card info, and even info on when to reorder. This reduces the size of your storage and complexity of web apps and can improve security.

7. Local retailers participation – Since this is P2P, anyone can be a part of the network, including the local retailer. What if you ordered a book? The local retailer could reserve it for you via a message from your computer to the store’s computer. You pick it up and save on shipping.

8. Extras – Now that you are on the desktop there are all sorts of things possible from games to integrating with the user’s calendar applications. Just use your imagination.

A P2P catalog is just one example of how JXTA can be used to enhance an idea and save money. There are other things that are cool about JXTA and P2P. More to come.

About Daniel Brookshier 1 Article
Daniel Brookshier is the lead author and editor of JXTA: Java P2P Programming. He is a hands-on Java architect concentrating on JXTA, J2EE, Swing, and mentoring. Daniel is an independent consultant with clients in multiple industries, including such well known companies as Boeing, Ericsson, and Wal-Mart. His two personal Web sites are http://people.jxta.org/turbogeek/ and www.cluck.com