Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Tuesday, September 16, 2014

What Is An API & What Are They Good For? [Technology Explained]






What Is An API & What Are They Good For? [Technology Explained]

  On
Offbeat Stuff, Technology Explained

Application Programming Interface and they say that APIs are the underlying aspect of Web 2.0.  But what does it really mean – what is an api? Let’s try to demystify the term a little.
The word to really pay attention to is “Interface”. If you have any experience at all with programming, all kinds of abstractions and contracts must be coming to your mind when you hear the word “interface” but we are more interested in the classical meaning of the term.
An interface is a common boundary between two separate systems. It is the means or the medium via which these two systems communicate.

Definition

An API is the interface implemented by an application which allows other applications to communicate with it.

Why Is It Needed?

In one word – communication. You might ask why communication is so important. Just imagine Notepad couldn’t copy-paste to and from Microsoft Word or Google Chrome. Imagine having to type each and every time although the text is already there in some other application. This is only one of the examples of communication between applications and all this communication is made possible via APIs.

What Is It Really?

You cannot run an API like you would run say a Notepad application. This is because APIs are generally invisible to the end users like you and me. APIs are carefully thought out pieces of code created by programmers for their applications that allow other applications to interact with their application.
APIs are specially crafted to expose only chosen functionality and/or data while safeguarding other parts of the application which provides the interface. Creating an API is indeed time well spent, because ultimately the more applications that interact with your application the more popular it becomes.
An excellent example is Twitter. Most people prefer their favorite Twitter client instead of the web interface. You can interact with Twitter whether you are using a mobile phone, a smart phone, an iPod or a computer. This has been made possible by the excellent Twitter API.
What Is It Good For?
As we have seen, APIs facilitate communication allowing different applications to communicate effectively with each other. So these are really well suited for extending a platform and for mashups. We have already seen Twitter as an example of how APIs are useful in extending a platform. When you combine data or functionality from more than one application to create another application, you have essentially created a mashup.
Such mashups are extremely popular on the Internet these days. The Internet thrives on communication so it is an ideal place to take advantage of APIs. It is a common practice to expose part of your functionality or data as an API to others on the Web. They can then tap into what you offer, combine it with what they (or someone else) offers and then provide improved and added functionality to their users.
Yelp for example has data on restaurants, hotels, shopping destinations and other local services but it would be a wasteful and tedious job if they set out to create their own Maps engine to let users know where the various destinations are. So instead they tap into the Google Maps API and plot their data on top of it, thereby increasing the utility of their service to the end user. This is a typical use of an API.
Popular APIs You Can Use Or Try
APIs are all over the place. The most popular ones are the Web APIs like Google Maps API, Twitter API and the Flickr API. These are not the only ones though. You can find a complete, classified and searchable directory of APIs at Programmable Web and WebMashup. Here you can see the level of interest in an API, what services are provided by the API and which services are making use of the API.
How you actually use an API depends upon your needs and your level of expertise. You might want to create the next big thing on the Internet, in which case you would most likely need to program for the Web using languages such as PHP, ASP.NET, Java or Python. A good starting point is to visit the official API page for the service you choose. Look for libraries others have written in the language of your choice. Usually these libraries make your job a lot easier and faster. Twitter for example mentions a number of these libraries on its API wiki. You can also find tutorials, official documentation and best practices on these pages.
APIs have existed in one form or another for a very long time. The first communication between cooperating applications may or may not have been through an officially documented API, but nowadays they are an important component of your application especially if yours is a Web application.
Have you ever created or used an API? We would love to hear about your experiences in the comments.




Monday, September 01, 2014

Yandex.Direct and Google AdWords compared



Google + Yandex

Yandex.Direct and Google AdWords compared

The Russian search engine marketing (SEM) market is unique and, to a large extent, different from the SEM-markets of other countries. The main difference lies in the fact that most of the search traffic is concentrated on the local search engine Yandex.
According to various estimates, Yandex’s share of search engine traffic in Russia ranges from 60% to 65%, while the share of Google, its closest follower, is about 25%. Thus, the main competition in the SEM market unfolds between the content providers Yandex.Direct and Google AdWords. In terms of functionality, these systems have differences.

  • Ad formats
Both systems place text ads but with different restrictions. The header length on Yandex.Direct can be no longer than 33 characters, while Google AdWords allows for 25. The length of text ads is limited to 75 characters on Yandex.Direct and to two lines 35 word long lines on AdWords. The average length of words in Russian is longer than in English.Long titles and texts characterize Yandex.Direct as being a system that suits the peculiarities of the Russian language better and is more adapted for the Russian market.
In 2013, Yandex introduced another ad format that is different from the Google AdWords formats. For advertisements that are placed on partner sites of Yandex’s advertising network (called YAN), it is now possible to add images. The main feature of this format is that it can be added for remarketing ads, which undoubtedly greatly increases their effectiveness.
  • Usability and flexibility
Yandex.Direct system has a relatively simple and intuitive interface. Its simplicity makes it more popular among Russian advertisers, especially those whose experiences in contextual advertising are relatively weak. However, for experienced advertisers, AdWords is a more user-friendly system that provides important tools for mass editing, flexible configuration, and quick optimization. All of these features make AdWords more attractive and very popular among advertisers with thousands, and even tens of thousands of ads and keyword phrases.
  • Manage advertising display position
Yandex Direct shows each advertiser the recommended rates for taking up a specific position in the contextual landscape that allows an advertiser to at least get the right ad block. Google AdWords does not give this opportunity to be in a requested position. This factor is an issue for Russian advertisers when dealing with AdWords.
  • Advertising networks
The major sources of traffic for both systems are their own search engines. However, both systems have a network of partner sites. The ad networks of both systems also includes a variety of content-based, news, entertainment, and business sites. In addition, Yandex.Direct shows up in the results of search engine portals Mail.ru and Rambler, which traditionally are third and fourth place in terms of search traffic.
The size and quality of these networks is difficult to compare objectively, but they can be compared on the flexibility of settings and placement targeting. Google AdWords offers more targeting options such as remarketing, targeting by user interest, targeting by site category, and targeting by keyword. Yandex offers the following targeting capabilities: retargeting, targeting by keyword, and targeting by user interest. However, it is impossible to control the interests, as they are automatically matched to the selected keywords. Yandex does not give a choice of partners for ad placement, while Google allows this. The format of ads placed on partner networks also differ. Yandex.Direct allows you to place text ads or text and image ads (ads with a picture), while Google AdWords allows you to place text ads, and banner ads in various formats, as well as promotional videos on Youtube.
  • Competition and cost-per-click
Having the largest share of the search market makes Yandex.Direct more attractive to advertisers than Google AdWords. Today, according to experts, the number of advertisers is over 350,000. Therefore, it is generally believed that competition on Yandex.Direct is greater and fast growth bid in many niches. As a result, cost-per-click (CPC) for Yandex.Direct in higher on average than for Google AdWords.
  • Management conversions and CPA
Every year Russian advertisers become more “advanced” and it is necessary to manage not only the placement of advertising, but also its economic returns. AdWords for many years now gives advertisers a tool that enables them to manage conversions with reference to CPA. Yandex has not yet provided anything like this. At the end of 2013, Yandex Direct finally released a similar tool, which allows the setting of weekly budgets and a desired target price action. Comparing the two tools is of course difficult. It can only be added that experts say the Yandex tool provides a significant impact on contextual media campaigns.
  • Availability API for third-party developers
The growth of Internet penetration in Russia and the fact that Russia has become the European country with the largest number of Internet users have resulted in the growth of keyword queries on search engines. This makes large advertisers develop their own applications for context systems for the automation various processes via API. Yandex.Direct API is open to virtually anyone, while Google AdWords accepts only large advertisers with high turnover and a payment history of no less than six months. In addition, advertisers are forced to undergo a certification process of their applications for the Google AdWords API, which is certainly a barrier.
  • Automation
The Russian contextual advertising market continues to grow at a rapid pace, which is resulting in a more complex environment for its management and control. Such a situation is driving the development of the automation advertising market in Russia. The period of 2013-2014 is marked by the advent of various automation systems. It is also worth noting the appearance of Russian startups in the segment, such as Alytics; the increased competition from foreign players like Marin Software and Adobe AdLens; and a change in strategy among market veterans, characterized by a round of new investments into the platform eLama.
  • Discount policy
Yandex.Direct has a special Discount policy for regular customers with large advertising budgets. The discounts can be as high as 23%. Google AdWords does not offer discounts to its customers.
*
Summing up the comparison of the two systems, there are several key points. Yandex.Direct is a leader in search engine traffic. Google AdWords provides more sophisticated and advanced tools for settings and targeting. Competition on Yandex.Direct is more intense than on Google AdWords. It is worth noting that, despite the many differences between the systems over the past few years, they approach each other and inevitably become more like each other. This trend will continue in the future, while each player will hope to come up with something unique to strengthen his position and push out his competitor.
Alexander Egorov is the Director of Development for the smart content platform Alytics. He is also an expert on CPA-campaigns and effective online media, and a consultant for CPA-contextual advertising campaigns. He has more than 9 years of experience in integrated online marketing (including to some degree within CPA and ROI) and contextual advertising campaigns for: Price.ru, Credit Bank of Moscow, Aeroflot Airlines, Tour Operators Pegas, DSBW and TezTour, Svyaznoy Bank, Saxo Bank, Central Department Store, MIAN, publisher Ferra, and the Finn Flare store.
This article is an excerpt from a comprehensive research study on Russian e-commerce and online marketing channels by East-West Digital News. To receive an executive summary at no charge please contact report@ewn.com. 

Wednesday, February 26, 2014

Cloud Foundry Blog

Cloud Foundry Blog


Posted: 22 Feb 2014 02:29 PM PST
Cloud Foundry (CF) is a platform-as-a-service that, once deployed, makes it easy for developers to deploy, run and scale web applications. Powering this elegant PAAS is a complex distributed system comprised of several interoperating components: the Cloud Controller (CC) accepts user input and directs Droplet Execution Agents (DEAs) to stage and run web applications. Meanwhile, the Router maps inbound traffic to web-app instances, while the Loggregator streams log output back to developers. All these components communicate via NATS, a performant message bus.
It’s possible to boil CF down to a relatively simple mental model: users inform CC that they desire applications and Cloud Foundry ensures that those applications, and only those applications, are actually running on DEAs. In an ideal world, these two states – the desired state and the actual state – match up.
Of course, distributed systems are not ideal worlds and we can – at best – ensure that the desired and actual states come into eventual agreement. Ensuring this eventual consistency is the job of yet another CF component: the Health Manager (HM).
In terms of our simple mental model, HM’s job is easy to express:
  1. collect the desired state of the world (from the CC via HTTP)
  2. collect the actual state (from the DEAs via application heartbeats over NATS)
  3. perform a set diff to find discrepancies – e.g. missing apps or extra (rogue) apps
  4. send START and STOP messages to resolve these discrepancies
Despite the relative simplicity of its domain, the Health Manager has been a source of pain and uncertainty in our production environment. In particular, there is only one instance of HM running. Single points of failure are A Bad Thing in distributed systems!
The decision was made to rewrite HM. This was a strategic choice that went beyond HM – it was a learning opportunity. We wanted to learn how to rewrite CF components in place, we wanted to try out new technologies (in particular: Golang and etcd), and we wanted to explore different patterns in distributed computing.
HM9000 is the result of this effort and we’re happy to announce that it is ready for prime-time: For the past three months, HM9000 has been managing the health of Pivotal’s production AWS deployment at run.pivotal.io!
As part of HM9000′s launch we’d like to share some of the lessons we’ve learned along the way. These lessons have informed HM9000′s design and will continue to inform our efforts as we modernize other CF components.

Laying the Groundwork for a Successful Rewrite

Replacing a component within a complex distributed system must be done with care. Our goal was to make HM9000 a drop-in replacement by providing the same external interface as HM. We began the rewrite effort by steeping ourselves in the legacy HM codebase. This allowed us to clearly articulate the responsibilities of HM and generate tracker stories for the rewrite.
Our analysis of HM also guided our design decisions for HM9000. HM is written in Ruby and contains a healthy mix of intrinsic and incidental complexity. Picking apart the incidental complexity and identifying the true – intrinsic complexity – of HM’s problem domain helped us understand what problems were difficult and what pitfalls to avoid. An example might best elucidate how this played out:
While HM’s responsibilities are relatively easy to describe (see the list enumerated above) there are all sorts of insidious race conditions hiding in plain-sight. For example, it takes time for a desired app to actually start running. If HM updates its knowledge of the desired state before the app has started running it will see a missing app and attempt to START it. This is a mistake that can result in duplicates of the app running; so HM must – instead – wait for a period of time before sending the START message. If the app starts running in the intervening time, the pending START message must be invalidated.
These sorts of race conditions are particularly thorny: they are hard to test (as they involve timing and ordering) and they are hard to reason about. Looking at the HM codebase, we also saw that they had the habit – if not correctly abstracted – of leaking all over and complicating the codebase.

Many Small Things

To avoid this sort of cross-cutting complexification we decided to design HM9000 around a simple principle: build lots of simple components that each do One Thing Well.
HM9000 is comprised of 8 distinct components. Each of these components is a separate Go package that runs as a separate process on the HM9000 box. This separation of concerns forces us to have clean interfaces between the components and to think carefully about how information flows from one concern to the next.
For example, one component is responsible for periodically fetching the desired state from the CC. Another component listens for app heartbeats over NATS and maintains the actual state of the world. All the complexity around maintaining and trusting our knowledge of the world resides only in these components. Another component, called the analyzer, is responsible for analyzing the state of the world — this is the component that performs the set-diff and makes decisions. Yet another component, called the sender, is responsible for taking these decisions and sending START and STOP messages.
Each of these components has a clearly defined domain and is separately unit tested. HM9000 has an integration suite responsible for verifying that the components interoperate correctly.
This separation of components also forces us to think in terms of distributed-systems: each mini-component must be robust to the failure of any other mini-component, and the responsibilities of a given mini-component can be moved to a different CF component if need be. For example, the component that fetches desired state could, in principle, move into the CC itself.

Communicating Across Components

But how to communicate and coordinate between components? CF’s answer to this problem is to use a message bus, but there are problems with this approach: what if a message is dropped on the floor? How do you represent the state of the world at a given moment in time with messages?
With HM9000 we decided to explore a different approach: one that might lay the groundwork for a future direction for CF’s inter-component communication problem. We decided, after extensive benchmarking, to use etcd a high-availability hierarchical key-value store written in Go.
The idea is simple, rather than communicate via messages the HM9000 components coordinate on data in etcd. The component that fetches desired state simply updates the desired state in the store. The component that listens for app heartbeats simply updates the actual state in the store. The analyzer performs the set diff by querying the actual state and desired state and placing decisions in the store. The sender sends START and STOP messages by simply acting on these decisions.
To ensure that HM9000′s various components use the same schema, we built a separate ORM-like library on top of the store. This allows the components to speak in terms of semantic models and abstracts away the details of the persistence layer. In a sense, this library forms the API by which components communicate. Having this separation was crucial – it helped us DRY up our code, and gave us one point of entry to change and version the persisted schema.

Time for Data

The power behind this data-centered approach is that it takes a time-domain problem (listening for heartbeats, polling for desired state, reacting to changes) and turns it into a data problem: instead of thinking in terms of responding to an app’s historical timeline it becomes possible to think in terms of operating on data sets of different configurations. Since keeping track of an app’s historical timeline was the root of much of the complexity of the original HM, this data-centered approach proved to be a great simplification for HM9000.
Take our earlier example of a desired app that isn’t running yet: HM9000 has a simple mechanism for handling this problem. If the analyzer sees that an app is desired but not running it places a decision in the store to send a START command. Since the analyzer has no way of knowing if the app will eventually start or not, this decision is marked to be sent after a grace period. That is the extent of the analyzer’s responsibilities.
When the grace period elapses, the sender attempts to send a START command; but it first checks to ensure the command is still valid (that the missing app is still desired and still missing). The sender does not need to know why the START decision was made, only whether or not it is currently valid. That is the extent of the sender’s responsibilities.
This new mental model – of timestamped decisions that are verified by the sender – makes the problem domain easier to reason about, and the codebase cleaner. Moreover, it becomes much easier to unit and integration test the behavior of the system as the correct state can be set-up in the store and then evaluated.
There are several added benefits to a data-centered approach. First, it makes debugging the mini-distributed system that is HM9000 much easier: to understand what the state the world is all you need to do is dump the database and analyze its output. Second, requiring that coordination be done via a data store allows us to build components that have no in-memory knowledge of the world. If a given component fails, another copy of the component can come up and take over its job — everything it needs to do its work is already in the store.
This latter point makes it easy to ensure that HM9000 is not a single point of a failure. We simply spin up two HM9000s (what amounts to 16 mini-components, 8 for each HM9000) across two availability zones. Each component then vies for a lock in etcd and maintains the lock as it does its work. Should the component fail, the lock is released and its doppelgänger can pick up where it left off.

Why etcd?

We evaluated a number of persistent stores (etcd, ZooKeeper, Cassandra). We found etcd’s API to be a good fit for HM9000′s problem space and etcd’s Go driver had fewer issues than the Go drivers for the other databases.
In terms of performance, etcd’s performance characteristics were close to ZooKeeper’s. Early versions of HM9000 were naive about the amount of writes that etcd could handle and we found it necessary to be judicious about reducing the write load. Since all our components communicated with etcd via a single ORM-like library, adding these optimizations after the fact proved to be easy.
We’ve run benchmarks against HM9000 in its current optimized form and find that it can sustain a load of 15,000-30,000 apps. This is sufficient for all Cloud Foundry installations that we know of, and we are ready to shard across multiple etcd clusters if etcd proves to be a bottleneck.

Why Go?

In closing, some final thoughts on the decision to switch to Golang. There is nothing intrinsic to HM9000 that screams Go: there isn’t a lot of concurrency, operating/start-up speed isn’t a huge issue, and there isn’t a huge need for the sort of systems-level manipulation that the Go standard library is so good at.
Nonetheless, we really enjoyed writing HM9000 in Go over Ruby. Ruby lacks a compile-step – which gives the language an enviable flexibility but comes at the cost of limited static analysis. Go’s (blazingly fast) compile-step alone is well worth the switch (large scale refactors are a breeze!) and writing in Go is expressive, productive, and developer friendly. Some might complain about verbosity and the amount of boiler-plate but we believe that Go strikes this balance well. In particular, it’s hard to be as terse and obscure in Go as one can be in Ruby; and it’s much harder to metaprogram your way into trouble with Go ;)
We did, of course, experience a few problems with Go. The dependency-management issue is a well-known one — HM9000 solves this by vendoring dependencies with submodules. And some Go database drivers proved to be inadequate (we investigated using ZooKeeper and Cassandra in addition to etcd and had problems with Go driver support). Also, the lack of generics was challenging at first but we quickly found patterns around that.
Finally, testing in Go was a joy. HM9000 became something of a proving-ground for Ginkgo & Gomega and we’re happy to say that both projects have benefited mutually from the experience.
Facebook Twitter Linkedin Digg Delicious Reddit Stumbleupon Email
You are subscribed to email updates from Cloud Foundry Blog
To stop receiving these emails, you may unsubscribe now.
Email delivery powered by Google
Google Inc., 20 West Kinzie, Chicago IL USA 60610

Saturday, February 08, 2014

Twitter’s use of cookies and similar technologies.

Twitter’s use of cookies and similar technologies

Mira este artículo en español.

Twitter uses cookies and other similar technologies, such as pixels or local storage, to help provide you with a better, faster, and safer experience. Here are some of the ways that the Twitter services—including our various websites, SMS, APIs, email notifications, applications, buttons, widgets, and ads—use these technologies: to log you into Twitter, save your preferences, personalize the content you see, protect against spam and abuse, and show you more relevant ads.
Below we explain how Twitter, our partners, and other third parties use these technologies, your privacy settings and the other options you have.

What are cookies, pixels, and local storage?

Cookies are small files that websites place on your computer as you browse the web. Like many websites, Twitter uses cookies to discover how people are using our services and to make them work better.
A pixel is a small amount of code on a web page or in an email notification. As many services do, we use pixels to learn whether you’ve interacted with certain web or email content. This helps us measure and improve our services and personalize your experience on Twitter.
Local storage is an industry-standard technology that allows a website or application to store information locally on your computer or mobile device. We use local storage to customize what we show you based on your past interactions with Twitter.

Why does Twitter use these technologies?

Twitter uses these technologies to deliver, measure, and improve our services in various ways. These uses generally fall into one of the following categories:
  • Authentication and security:
    • To log you into Twitter
    • To protect your security
    • To help us detect and fight spam, abuse, and other activities that violate the Twitter Rules
For example, these technologies help authenticate your access to Twitter and prevent unauthorized parties from accessing your account. They also let us show you appropriate content through our services.
  • Preferences:
    • To remember information about your browser and your preferences
For example, cookies help us remember your preferred language or country that you are in. We can then provide you with Twitter content in your preferred language without having to ask you each time you visit Twitter. We can also customize content based on your country, such as showing you what topics are trending near you, or to withhold certain content based on applicable local laws.  Learn more about Trends and country withheld content.
  • Analytics and research:
    • To help us improve and understand how people use our services, including Twitter buttons and widgets, and Twitter Ads
For example, cookies help us test different versions of our services to see which particular features or content users prefer. We might also optimize and improve your experience on Twitter by using cookies to see how you interact with our services, such as when and how often you use them and what links you click on. We may use Google Analytics to assist us with this. Learn more about the cookies you may encounter through our use of Google Analytics.
  • Personalized content:
    • To customize our services with more relevant content, like tailored trends, stories, ads, and suggestions for people to follow
For example, local storage tells us which parts of your Twitter timeline you have viewed already so that we can show you the appropriate new content. Cookies can help us make smarter and more relevant suggestions about who you might enjoy following based on your recent visits to websites that have integrated Twitter buttons or widgets. We can suggest people who are frequently followed by other Twitter users that visit the same websites. Learn more about tailored suggestions and your privacy controls, which include your Twitter account settings and Do Not Track browser setting.
  • Advertising:
    • To help us deliver ads, measure their performance, and make them more relevant to you based on criteria like your activity on Twitter and visits to our ad partners' websites
For example, we use cookies and pixels to tailor ads and measure their performance. Using these technologies, we can show you ads and evaluate their effectiveness based on your visits to our ad partners' websites. This helps advertisers provide high-quality ads and content that might be more interesting to you. Learn more about tailored ads and your privacy controls, which include your Twitter account settings, Do Not Track browser setting, and the opt-out pages of Twitter's ad partners.

Where are these technologies used?

Twitter uses these technologies on our own websites and services and on other websites that have integrated our services. This includes our advertising and platform partners’ websites and sites that use Twitter buttons or widgets, like our Tweet or follow buttons. Third parties may also use these technologies when you interact with their content from within our services, like when you click a link or stream video on Twitter from a third-party website.

What are my privacy options?

We are committed to offering you meaningful privacy choices.  You have a number of options to control or limit how Twitter, our partners, and other third parties use cookies:
  • For tailoring suggestions on Twitter: If you do not want Twitter to tailor suggestions for you based on your recent visits to websites that have integrated Twitter buttons or widgets, you can turn off this feature using your Twitter account settings or Do Not Track browser setting. This removes from your browser the unique cookie that enables the feature. Learn more here.
  • For tailoring ads on Twitter: If you do not want Twitter to tailor ads based on our ad partners’ information, including cookies, you can turn off this feature using your Twitter account settings, Do Not Track browser setting, or the opt-out pages of Twitter's ad partners. Then Twitter will not match your account to cookie or other information shared by our ad partners for tailoring ads. Learn more here.
  • For using cookies: You can modify your settings in most web browsers to accept or deny all cookies, or to request your permission each time a site attempts to set a cookie. Although cookies are not required for some parts of our services, Twitter may not work properly if you disable cookies entirely. For example, you cannot log into Twitter.com if you've disabled all cookie use.

Where can I learn more?